webfont icon indicating copy to clipboard operation
webfont copied to clipboard

feat: randomize files name

Open Malin88 opened this issue 7 years ago • 5 comments

How can I randomize font files name? I have some problem with browser cache so I want to generate file like webfont.scss with src: url("[some-random-string]") How can I do that ?

Malin88 avatar Jan 22 '18 10:01 Malin88

@Malin88 you can use custom template also we can add option to pass custom variables into template, PR welcome

alexander-akait avatar Jan 23 '18 09:01 alexander-akait

use option fontName:

{ 
   fontName: webfont-${Math.random().toString(36).substring(7)} 
}

alexander-akait avatar Mar 21 '18 13:03 alexander-akait

thx, but this option did not do what I expected. After I used it got font files like webfont-asd34cxf.eot and also scss files with the same name webfont-asd34cxf.scss so after any font regeneration, I need to update file name of included font :/

Malin88 avatar Mar 26 '18 10:03 Malin88

Don't use Math.random(). This exact problem is widely solved by including a hash of the contents in the filename. Even an old algorithm like MD5 is fine for this purpose, since there's no security impact. That is a far better solution, since only changes that affect the webfont data will cause a filename update.

jwhitley avatar Jul 16 '20 18:07 jwhitley

How can I randomize font files name? I have some problem with browser cache so I want to generate file like webfont.scss with src: url("[some-random-string]") How can I do that ?

@Malin88 do you believe that adding a cache querystring and/or version querystring would meet your need?

jimmyandrade avatar Sep 29 '20 22:09 jimmyandrade