Everytime we make a release the users need to clear their cache for the new code to take effect. Is there a way to have this done automatically?
Asked
Active
Viewed 794 times
2
-
Is this an include on a site? Is this third-party Javascript that you have no control over the include statement? Need more details. – mVChr Dec 14 '12 at 22:21
-
check if desired resourced changed ( probably in serverside code ) , pass that value to client side (statically or dynamically through ajax ) and the in javascript : `if (resource_changed) location.reload(true);` sth like this – sakhunzai Dec 14 '12 at 22:33
-
Hi, did you solve this problem ? – Daniel Flores Oct 15 '14 at 21:10
-
There are lots of ways to do it. If you are working on nodejs , sailsjs related environment I could give you a better solution. – Mad Dec 08 '16 at 10:25
2 Answers
0
If you're talking about a Javascript include on a website then you can just append a query string with an incremented version number. So one release would be:
<script src="codebase.js?v=1"></script>
and the next release would be:
<script src="codebase.js?v=2"></script>
If you're talking about a third-party hosted file that you don't have control over their script include then the problem is more difficult.

mVChr
- 49,587
- 11
- 107
- 104
-
That's actually the technique that we use (appending a new version number) but it still happens. I don't know what can be done about this. – SBel Dec 17 '12 at 15:27
-
We are having a discussion about the same issue, in my mind it's a server-side issue. The version number needs to be added to files in some way, maybe a rewrite to include the path or to append the version number as in the example above. We are running IIS so I have to do some research on it but I think some sort of URL rewrite is the way to go. And to make sure that the page being served is "touch"-ed as well. Suspenders and a belt. :) – Mats Sep 07 '15 at 08:12