When does browser automatically clear cache of external JavaScript file?

You may pass a version string as a get parameter to the URL of your script tag. The parameter won’t be evaluated by the static JavaScript file but force the browser to get the new version.

If you do not want to assign the version string every time you edited the source you may compute it based on the file system time stamp or your subversion commit number:

<script src="https://stackoverflow.com/script.js?time_stamp=1224147832156" type="text/javascript"></script>
<script src="/script.js?svn_version=678" type="text/javascript"></script>

   

Leave a Comment