2

I have big problem with chrome's cache. I'm building system for my clients. All are build on angular so at the begining there is always one index.html file. With new version I'm changing js scripts tag to ex. scripts.2.1.1.js in index.html file. I have also:

<FilesMatch "\.(html)$">
Header set Cache-Control "max-age=1, public"
</FilesMatch>

in my htaccess file.

But chrome seems to ignore it. Every time when I type in url address I have old version, but in source code I have tags to new scripts. When I press F5 it loads new version, but when I close browser's tab and type in url once again I have old version once again?

What's wrong? How to get rid of cache? I don't want a browser solution (clearing cache). I can't force my clients to do that. I want server-side solution. Is there any?

Solution:

<FilesMatch "\.(html|js|css)$">
Header unset ETag 
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" 
Header set Pragma "no-cache" 
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" 
</FilesMatch>
piernik
  • 3,507
  • 3
  • 42
  • 84
  • Here is one small work around for the temporary solution, open that view file in new tab in browser and press ctrl+f5 one time after make change, and then try in you app by reloading. It will works definitely. – Jigar7521 Oct 17 '16 at 11:18
  • I can't force my clients to do that - I'm looking for true solution. – piernik Oct 17 '16 at 11:21
  • As i have already said you, this was temporary solution. – Jigar7521 Oct 17 '16 at 11:22

1 Answers1

3

You could try to set "no-store" in the header: Why both no-cache and no-store should be used in HTTP response?

But Implementing ETag headers is a more robust way to do so:

https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching?hl=en

Community
  • 1
  • 1
wbrmx
  • 71
  • 3
  • I'm trying ` Header unset ETag Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" ` - no luck – piernik Oct 17 '16 at 11:21