-
Notifications
You must be signed in to change notification settings - Fork 822
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
Fallback to network on navigationRoute cache miss #1300
Conversation
PR-Bot Size PluginChanged File Sizes
New FilesNo new files have been added. All File SizesView Table
Workbox Aggregate Size Plugin☠️ WARNING ☠️We are using 154% of our max size budget. Total Size: 22.63KB Gzipped: 9.08KB |
}).catch((error) => { | ||
if (process.env.NODE_ENV !== 'production') { | ||
logger.debug(`Unable to respond to navigation request with cached ` + | ||
`response: ${error}. Falling back to network.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be error.message
or you should log it as a separate log call (possibly in a group).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I set a setCatchHandler
what happens? Won't this change block it from working as intended?
Why don't we just have a default catch handler that is just the network given the lengths we are going to basically try and fallback to the network.
Prior to this PR, any With this PR, any So that's a change in behavior for developers who are already using The argument in favor of this PR is that if we're in a world where "unexpected" cache misses are more likely, developers who would not think to use a
|
logger.debug(`Unable to respond to navigation request with cached ` + | ||
`response: ${error.message}. Falling back to network.`); | ||
} | ||
return fetch(cachedAssetUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this the default setCatchHandler? It's in the router module, not the strategy.
@jeffposnick I'm confused by your comment:
This PR is a single change to the Router module. |
Apologies about that confusion. Serves me right for putting out different PRs in flight at the same time. |
@jeffposnick is this still relevant? |
It's still relevant, but it's not something we need to get implemented in time for v3. I'd like to revisit some of the "cache resiliency" issues for a minor release, post v3. |
CC: @philipwalton So I wanted to revisit this, particularly in light of #1441, in which I believe @coryrylan is bumping up against this edge case. (As far as I can tell this scenario the most likely culprit.) To clarify some of the crossed wires in response to the initial feedback: This is a focused changes that detects one of two possible failure modes when the handler associated with
If that Asking a user to manually deal with this situation via their own global
I took another pass through the code and added some comments to clarify these points, but I think it's a safe bet to move ahead with. (And it matches what we were doing in |
(Also, this PR uses |
I'm good with this change, and I think falling back to network anytime we're dealing with cache (with the possible exception of cache only) is probably safest. |
Thanks, @philipwalton. I'll close this and merge a fresh PR that contains the equivalent change with |
R: @addyosmani @gauntface
This is 1/3 of #1188
It adds network fallback behavior to the
workbox-routing
's navigation route in the default export.