Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2/4 template cache-busting is not working

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`?

like image 429
DominikP Avatar asked Apr 25 '26 11:04

DominikP


1 Answers

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

like image 77
DominikP Avatar answered Apr 28 '26 03:04

DominikP



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!