I have a quite troublesome issue which I didn't find a good solution for yet.
I allow caching of all my application static files (JS, CSS and images) by browser for performance.
Problem is, when I'm doing upgrades, the users still use the old version from their cache, which often breaks the application, and requires clearing the cache every time to solve the problem.
Is there any good multi-browser approach which still allows caching the files, but can force to reload them when needed?
Thanks for any info.
Append somethign to the URL as parameter, e.g.
myresource.css?version=1
. The file will be servered correctly, that's a trick to force reloading the cache. You only need to generate the html page dynamically.I've heard talk of using version numbers in the filenames you want you users caching, but I can't speak to how "good" that is compared to other options.
You can use below format for auto random versioning
for js file:
<script type="text/javascript" src="js/app.js?seq=<%=DateTime.Now.Ticks%>"></script>
and for css file:
<link rel="stylesheet" type="text/css" href="Styles/styles.css?seq=<%=DateTime.Now.Ticks%>" />
Options I can think of: