Prevent IE from aggressively caching API responses
This was not an issue in Google Chrome but IE10’s caching of API responses was pretty aggressive. I was displaying some data to the users after a GET request and letting them make some changes. After sending the changes to the backend, I was making a GET request again to fetch the latest data but IE10 would show the cached data from the first GET request. It took a while to figure out what the issue but after that the fix was straightforward - set a Cache-Control: no-cache header on each request.
UDPATE
For Angular 4.3+, when using HttpClient, setting the header on each request can be achieved using Interceptors.
Here’s an interceptor that intercepts each http request and adds three headers.
This is then used by adding the below code to app.module.ts.
To use multiple interceptors, simple add them both as shown below while setting multi: true.