Cache API now rejects unsuccessful responses

Published: | Categories: DOM

Description

Previously, the Cache.add and Cache.addAll methods were storing 4xx and 5xx error responses from fetch. This behaviour had confused developers, therefore the spec has been changed to reject any responses with a non-2xx HTTP status code where the Response.ok property becomes false, and raise a TypeError. Firefox 46 and later follow the updated spec.

As a side effect, those methods will always reject opaque responses returned as the result of no-cors cross-origin requests, because such responses have the 0 status code instead of the actual code. This is a rare case at this moment according to the Blink team.

References