-
Notifications
You must be signed in to change notification settings - Fork 826
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
Allow precaching "repair" when using subresource integrity #2921
Conversation
(Actually, hold off on the review. I noticed something that needs to be changed when testing locally.) |
...I realize now that the code in this PR will work if there's an |
I've got a more robust approach, but it's blocked on #2914 (we need to be able to check the |
R: @tropicadri
Fixes #2858
Although unexpected, there are edge cases where the precache might not be in an inconsistent state, most likely due to a developer manually deleting something in DevTools.
When this happens,
workbox-precaching
defaults to falling-back to using a network response (assuming the device is online) when there's a precaching miss. Up until now,workbox-precaching
hasn't attempting to use this network response to repopulate the precache, because there are no guarantees that the network response corresponds to the version of the asset specified in the precache manifest.However, if the precache entry includes an
integrity
property, then subresource integrity guarantees that the response does correspond to the same version of the asset in the manifest. So it should be safe to "repair" the cache with that response.(The
revision
field can't be used for this purpose, because while it's traditionally set to the hash of an asset's content, it could theoretically be set to anything, and it would be much too expensive to calculate the hash of the response body via JavaScript at runtime.)