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?

7
  • Looks like a dup of stackoverflow.com/questions/34808023/…, stackoverflow.com/questions/39849122/… Commented Oct 7, 2016 at 4: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. Commented Oct 7, 2016 at 5:10
  • 2
    I think I have fixed my issue by adding "applicationCache.update();". Doing more testing now.... Commented Oct 7, 2016 at 5: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 Commented Nov 10, 2016 at 11:35
  • 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 - 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? Commented Dec 2, 2016 at 4:09

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.