0

I want to ensure users always get the latest version of my code. However setting it up so that browsers do not cache the files is bad as it would need to be loaded fresh every page view. I want to ensure it doesn't use a cached copy from a previous release.

One way I have seen involves changing the filename on each release, but don't know how to do it for index.html? I have couple of js files in index file.

<script language="JavaScript" src="js/gen_validatorv31.js" type="text/javascript"></script>
Medoju Narendar
  • 185
  • 1
  • 4
  • 18
  • This seems like a duplicate. Check out this question: http://stackoverflow.com/questions/7413234/how-to-prevent-caching-of-my-javascript-file – leemac Jul 07 '15 at 17:27
  • Asked many times here... build system with querystring is best bet – epascarello Jul 07 '15 at 17:27
  • If you version your assets (scripts, css, etc) and put then in a different path (e.g. `/css/2.x.x/file.css`) then even if the index.html is loaded from cache it will only load the relevant assets. When a new version of index.html is requested, new versions of the assets (with a different path) will be loaded. – lemieuxster Jul 07 '15 at 17:28
  • I might also add it depends on what your using to develop your site (Ruby/Django/ASP.NET/etc). Each has a well-regarded method of cache-busting on each version. – leemac Jul 07 '15 at 17:28
  • Regarding your index.html : http://stackoverflow.com/questions/13321335/load-index-html-every-time-from-the-server-and-not-from-cache – Nicolai S Jul 07 '15 at 17:28
  • if i use meta tag will it works for js file also or shall add the random number to the js file – Medoju Narendar Jul 07 '15 at 17:52

0 Answers0