Well, I have a big online application that many user uses in my office. It has extensive code of AJAX etc Javascript and JQuery. The problem is - whenever i update some code/function - I or any other user has to press Control+F5 in order to take the new changes into effect.
I do not want this, I want that whenever I upload new files / new codes it applies without pressing Control+F5 or in simple words it should not load from cache.
What are the possibilities and different ways to tackle this problem ? Is there anything I can do with PHP or .Htaccess to ENFORCE NO CACHE policy for all pages and ajax scripts ?
Configure your server to send headers that will prevent caching for .js files (I will not help with that one )
Add something random to URL of the .js file using PHP:
Formally, that method will produce a new URL for the same script each time, so browser will not use cache.
And of course, don’t forget to remove that code later on.
Even better if you add something static to the URL (like new version number) when you’re done with updates:
<script src="/path/to/script.js?v=2015-09-08">
That will allow users to recache your script just once, when there is a real need to do that.
Yes, that is forcing there to be no cache at all, which seems to be inferior to the etag solution where it’s cached only until a more recent change occurs.