2

I work on Angular 4, I have a language list and each list has a star beside it. As soon as the user clicks on star the language is added to favourites.

Issue: Ones I click on star the language appears to be added to the favourite list but when I refresh the page the previously selected favourite is not reflected (call to database doesnot goes, changes does not get reflected to database).

Bigger Issue: When I open the dev tool of IE and add a language to favourites, it shows in the favourites panel and if the refresh the page then also the previously selected favourite is present there (database is called and changes are reflected to database).

So, if the IE dev tool is open there is no issue and everthing works fine, when I close the dev tool the favourite added or deleted list doesnot appears on page load. There is no error in the console (except SockJS reconnect and I dont know what this is, we are not using SockJS). How am I suppose to debug this issue? What can the problem be when the dev tool is closed?

Anna
  • 1,669
  • 7
  • 38
  • 63
  • For fwiw the IE dev tools has an option that will disable caching when the tools are open. Which might be turned on in your case. That might explain why the behavior is different with the tools open. You can change this behavior in the network tool. It's the 4th command from the right in the network tool "Always refresh from server" and you can toggle it on/off. – Andy Sterland Feb 24 '19 at 20:26

1 Answers1

0

you have to prevent cache for get requests, internet explorer get data from cache when you trigger a get a request. you have to add no-cache in your header.

const apiHeaders = new HttpHeaders({ 'Content-Type': 'application/json',
 'Cache-control': 'no-cache, no-store, must-revalidate',
 'Pragma': 'no-cache',
 'Expires': '-1'
});
...

return this.http.get(uri, { headers: apiHeaders})
Fateh Mohamed
  • 20,445
  • 5
  • 43
  • 52