webfont
webfont copied to clipboard
feat: randomize files name
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 you can use custom template also we can add option to pass custom variables into template, PR welcome
use option fontName
:
{
fontName: webfont-${Math.random().toString(36).substring(7)}
}
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 :/
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.
How can I randomize font files name? I have some problem with browser cache so I want to generate file like
webfont.scss
withsrc: 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?