Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use response.status === 200 instead of response.ok for cacheability #1804

Closed
jeffposnick opened this issue Dec 20, 2018 · 0 comments
Closed
Labels
Milestone

Comments

@jeffposnick
Copy link
Contributor

Library Affected:
workbox-core, workbox-strategies

There are a couple of places where we default to checking response.ok to determine whether a given response is cacheable or not. (This can be overridden by workbox-cacheable-response, but we're talking about the defaults.)

response.ok is true iff 200 <= response.status <= 299. Unfortunately, there are some scenarios where we don't want to cache responses in that range, like when response.status === 206 (for partial content). Attempting to cache that type of response will fail as per the Cache Storage API.

Rather than go with response.ok && response.status !== 206 as the default criteria, I think we should just switch to response.status === 200 as the default, unless folks have a strong use case for caching other 2xx status responses by default. We'll continue to allow opting-in to custom cacheability criteria using workbox-cacheable-response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants