I'm currently working on a webapp and the Javascript is revised fairly often. However, the changes don't occur until the browser cache is refreshed manually. Is there a way to implement cache-refreshing automatically through code for Chrome? Thanks.
1 Answer
You can put something like ?2352352 at the end of your JS file. So something like
<script src='myfile.js?20457207'></script>
Where the number randomizes, forcing the browser to think it's a different file.
4 Comments
jamesfzhang
This looks like a solution but I'm not sure what the implications are. So we're currently using TortoiseSVN. Does anyone know if there's a way to automatically have TortoiseSVN prepend a comment with the version# of the commit every time a new version is committed?
Lars Blåsjö
A random number may be convenient during development, but in production a version number is a lot better, so the file can be cached as long as there is no new version. Using a random number, the file will never be cached, and downloaded at each page view, even if the js file has not been changed.
Marshall
Very true. A random int will force it to pull as new each time.