Search code examples
angularjsgoogle-chromehttpcache-control

Angular $http callbacks not working for HTTP 304 in Chrome


I am encountering a problem with Angular 1.5 and I could not find a similar question via Google. For a welcome change, the problem does not exist in IE, it only happens in the latest version of Chrome.

When I approach a JSON API and I send the same GET request twice in a row, the first request returns a 200 OK and the second returns a 304 NOT MODIFIED. I am doing the request with 'Cache-Control': 'no-cache' to simulate how our (generated) API client performs requests. With cache control enabled, both requests are executed correctly (see F12) and the program terminates. With cache control disabled, both requests are executed correctly (F12) but the program does not terminate.

Is this a bug in Chrome, or a bug in Angular's $http, or am I missing some crucial detail?

Minimal example on JsFiddle

Output:

Hi
Sending request 1 to http://jsonplaceholder.typicode.com/posts/1...
Success 1!
Resolved 1!
Sending request 2 to http://jsonplaceholder.typicode.com/posts/1...

Solution

  • Fixed after a Google Chrome update.