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.
Asked
Active
Viewed 1,062 times
1
-
2I never have this problem. Are you sure it's Chrome that is doing the caching, as opposed to your site? – maxedison Sep 29 '11 at 16:18
1 Answers
8
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.

Marshall
- 4,716
- 1
- 19
- 14
-
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? – jamesfzhang Sep 29 '11 at 16:31
-
-
4A 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. – Lars Blåsjö Sep 29 '11 at 17:27
-