Repository navigation
fix(service-worker): cache opaque responses in data groups with freshness strategy
#30977
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
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cb71a13
test(service-worker): remove obsolete async test helpers
gkalpak a725e1d
test(service-worker): simplify test helpers
gkalpak 60c406b
test(service-worker): properly reset mock server state for each test
gkalpak b54d0a9
test(service-worker): better simulate opaque requests
gkalpak 1fc2e3b
refactor(service-worker): make the caching behavior more explicit
gkalpak ea9f116
fix(service-worker): cache opaque responses in data groups with `fres…
gkalpak be5109a
fix(service-worker): cache opaque responses when requests exceeds tim…
gkalpak 9f10975
refactor(service-worker): remove redundant cache operation
gkalpak b8b61c7
fixup! test(service-worker): better simulate opaque requests
gkalpak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Isn't this going to cause non-200 opaque responses to be cached?
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.
Yes (if
okToCacheOpaqueistrue, which is only the case when handling aDataGrouprequest with freshness (i.e. network first)).With opaque responses, one can't tell if it was successful or not (
res.statusis0, thusres.okwill always befalse). So, what we do is that we cache opaque responses forDataGrouprequests that are configured to fetch from the network first. So, if the client is online, the SW should fetch the response from the network anyway (and not use the cache), but if the client is offline, the SW will serve the cached response. There is little risk (other than the extra memory), because the request would have failed anyway when offline.