Reputation: 3046
I've seen other approaches that attach a version number or MD5 hash to a JS src querystring.
e.g. <script src='/script/v1/'></script>
However, my JavaScript is still getting cached in multiple browsers (Chrome, Firefox) when I push a new version of my site.
This seems like a major problem that others have solved, and I seem to be doing the right things. How can I get this to work?
Upvotes: 1
Views: 9252
Reputation: 3046
I added log messages and determined that the querystring method is working. Sorry for the unnecessary question.
However, in researching, I found some important points worth mentioning:
Upvotes: 7
Reputation: 9801
1.)make sure the response headers for the javascript files are correct and include expires, cache-control, etc.
2.)you probably have to append the version not as a query parameter but part of the filename, e.g. page_v.2.js. You could change the javascript filenames at build time for example if you are using Java. That is what i have done.
Upvotes: 0
Reputation: 2426
It will be cached always. Although, by using a version number (or any other varying string) a new version will be downloaded and used every time, ignoring the previous one.
http://davidwalsh.name/prevent-cache
Upvotes: 1