How to force the browser to reload cached CSS/JS files?

后端 未结 30 4346
青春惊慌失措
青春惊慌失措 2020-11-21 05:49

I have noticed that some browsers (in particular, Firefox and Opera) are very zealous in using cached copies of .css and .js files, even be

30条回答
  •  悲哀的现实
    2020-11-21 06:12

    It seems all answers here suggest some sort of versioning in the naming scheme, which has its downsides.

    Browsers should be well aware of what to cache and what not to cache by reading the webservers response, in particular the http headers - for how long is this resource valid ? was this resource updated since I last retrieved it ? etcetera.

    If things are configured 'correctly', just updating the files of your application should (at some point) refresh the browsers caches. You can for example configure your web server to tell the browser to never cache files (which is a bad idea).

    A more in-depth explanation of how that works is here https://www.mnot.net/cache_docs/#WORK

提交回复
热议问题