Home > Software design >  Best ways to enforce browser to reload css file
Best ways to enforce browser to reload css file

Time:04-28

we are looking for a way to force the browser to always load the latest version of a css file.

We have added versioning to the file:

style.min.css?v1.0

But the old version still loads. Any thoughts?

CodePudding user response:

Your versionning syntax seems not to be good : it's should look like this :

style.min.css?v=1.0

CodePudding user response:

Adding ?v{{version}} is ideal to tell the browser there was a change in the file; one way you can do this is create a random number on document load and assign that random version number dynamically when rendering the link href; this will always cause the browser to see a "new" version;

Secondly, there are htaccess caching procedures you may want to explore if you have access to this - you can specify a caching policy to force the browser to purge and load your css as well.

  • Related