1

I am working on Angular2 project and got an issue that Chrome caches HTML templates. It is not a problem for the development since I can make cache to be ignored in Chrome Dev mode.

But it is a real pain for the customer and his users... I tried to add following to templateURL:

templateUrl: './pages/add-financial-deal.html?v=201610070907',

Updated URL is added into auto-generated JS but Chrome still uses cached JS even if I click Shift + F5. Checkout screenshot: http://screencast.com/t/bc2nf4zVcm

Is there any reliable way to get it working?

Thanks

Edit: Decmber 2nd

I have finally figured out what happening there. Despite the fact that I have added changes into TS (and auto-generated JS was also updated) Chrome is still loading file from in-memory cache - screencast.com/t/FGuaMXaKL . I have been waiting for 30 mins, but it still loads in-memory cached file. Is it intended behavior? How to avoid this?

Renat Khabibulin
  • 183
  • 2
  • 11
  • Looks like a dup of http://stackoverflow.com/questions/34808023/how-to-clear-template-cache-angular-js-2-0, http://stackoverflow.com/questions/39849122/angular2-refresh-component-template/39850540#39850540 – Günter Zöchbauer Oct 07 '16 at 04:39
  • Not really I think...I don't need all templates reload. And it seems that I don't need HTML reload but JS reload. – Renat Khabibulin Oct 07 '16 at 05:10
  • 2
    I think I have fixed my issue by adding "applicationCache.update();". Doing more testing now.... – Renat Khabibulin Oct 07 '16 at 05:10
  • appending "?v=....." to template url partially resolved an issue. At the moment I have another issue not related to Angular2 itself. Chrome caches JS ! And shift + F5 doesn't help – Renat Khabibulin Nov 10 '16 at 11:35
  • What about Ctrl+F5? – Günter Zöchbauer Nov 10 '16 at 11:39
  • 1
    I have finally figured out what happening there. Despite the fact that I have added changes into TS (and auto-generated JS was also updated) Chrome is still loading file from in-memory cache - http://www.screencast.com/t/FGuaMXaKL . I have been waiting for 30 mins, but it still loads in-memory cached file. Is it intended behavior? How to avoid this? – Renat Khabibulin Dec 02 '16 at 04:09
  • Have you tried Ctrl+F5? – Günter Zöchbauer Dec 02 '16 at 06:12

1 Answers1

1

I have finally fixed an issue which was actually 2 issues:

  1. HTML templates were cached. This was fixed by adding extra parameter into template URL, like "template.html?v=201612041641"
  2. JS files were staying in Chrome in-memory cache. Despite the fact that it should be kinda fast cache JS were cached for hours and hours. And Ctrl/Shift + F5 does not affect in-memory cache. Also, I tried to set cache control to "no-store, no-cache" in root html page. Finally, I set extra header into IIS Response header option "Control-Cache:no-cache" and now it works. JS files are stored on hard drive Chtome store, 304 status is recieved and changed files are properly updated
Community
  • 1
  • 1
Renat Khabibulin
  • 183
  • 2
  • 11