3

We have a Problem with our Angular 4 application regarding cache-busting. It seems, that old template-files are cached when we release new versions (Ctrl + F5 solves the problem).

We use angular-cli (--prod) to build our application which should handle cache-busting when new versions are released. The compiled js-file-names contain a hash-number for every version so that files won't be cached. And the html should be included in the javascript-files. Still old template-stuff seems to be cached.

One possible solution might be this one here: How to prevent Browser cache on Angular 2 site? Why should this change anything as not the template but js-files are requested? What's the best solution for this problem`?

DominikP
  • 151
  • 1
  • 10
  • Did you make sure that it's not the main page (index.html) itself that is cached ? – David Nov 29 '17 at 13:12
  • Actually this might be the problem. Is it good practise to use the cache-control meta-tag for this? (https://stackoverflow.com/a/1341133/3584607) – DominikP Nov 29 '17 at 15:23
  • Would this also effetc image-caching, javascript...? – DominikP Nov 29 '17 at 15:23
  • It depends on the browser and the cache meta added by your web server (apache, nginx) – David Nov 30 '17 at 10:12
  • I used a non-trivial solution, but one that eliminates all type cache issues in angular 6 (browser, cdn, proxies/isp cache) see (https://stackoverflow.com/a/54538027/1544054) – Aviko Feb 19 '19 at 08:15

1 Answers1

1

The solution was to set cache-expires header for the index.html file in our amazon S3-bucket.

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html#ExpirationAddingHeadersInS3

DominikP
  • 151
  • 1
  • 10