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

Ensure bad responses aren't cached #2738

Merged
merged 4 commits into from Jan 29, 2021
Merged

Ensure bad responses aren't cached #2738

merged 4 commits into from Jan 29, 2021

Conversation

jeffposnick
Copy link
Contributor

R: @philipwalton

Fixes #2737

This was a regression introduced in Workbox v6's modified precaching logic. This PR ensures that a bad response isn't saved to the cache before installation is halted.

Copy link
Member

@philipwalton philipwalton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach LGTM (just noticed a few spelling/grammar issues in the comments).

One thought though: instead of adding conditionally adding and removing defaultPrecacheCacheabilityPlugin, did you consider just always adding and removing it? E.g. before the install event happens, always add it if needed and then always remove it afterward.

Since it only applies to the install event, and since you have to make the check anyway, perhaps keeping it from running during fetch events is good in general.

packages/workbox-precaching/src/PrecacheStrategy.ts Outdated Show resolved Hide resolved
packages/workbox-precaching/src/PrecacheStrategy.ts Outdated Show resolved Hide resolved
@jeffposnick
Copy link
Contributor Author

After discussing offline, it's not possible for the PrecacheStrategy to run code once, at a point in time right before the install event happens. That's something that only the PrecacheController could do, and I want to ensure that PrecacheStrategy behaves properly even if it's not called by PrecacheController.

@jeffposnick jeffposnick merged commit b2e4c72 into v6 Jan 29, 2021
@jeffposnick jeffposnick deleted the precaching-fix branch January 29, 2021 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

workbox-precache caches error responses
2 participants