Update browser cache for multiple resources (CSS and Javascript)

I am developing a website that is currently under testing.

Whenever I make some significant changes to Javascript and CSS, my testers tell me a lot of new bugs, some of which are pretty harsh. However, they are all called by browsers that cache JS scripts and a CSS file, and using older versions with new HTML. Also, since this is a test version, I have about 10 separate JS files associated with tags <script type="text/javascript" src="..."></script>. It is possible to update the stylesheet manually, but ask the testers to go through each JS file and update it a bit.

Is there a way to tell the browser that related files have been updated and need to be reloaded?

+5
source share
2 answers

Add "cache bitter" in url, i.e. add the query string parameter.

<script src="foo.js"></script>

becomes

<script src="foo.js?v=1"></script>

If you are doing phased releases, you can simply use the release version as a cache.

+8
source

How to add random string to file name? For example, a time stamp.

style.css?123456

This should help.

+1
source

All Articles