-
Notifications
You must be signed in to change notification settings - Fork 830
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
workbox-precache caches error responses #2737
Comments
Hello! The expected behavior is that any responses with 4xx or 5xx statuses should not be precached by default, and cause the service worker installation to fail: workbox/packages/workbox-precaching/src/PrecacheStrategy.ts Lines 148 to 154 in 3151c3a
Are you possibly passing in a |
...what also leads me to believe that your screenshot either shows a cache created by a much earlier version of Workbox than v6.0.2, or alternatively, that your service worker file includes additional code that you didn't include, is that your precache is named The default precache name in Workbox v6.0.2 ends in workbox/packages/workbox-core/src/_private/cacheNames.ts Lines 30 to 36 in 3151c3a
|
@jeffposnick our project start using Workbox from v5, cache names was not changed. Later project have been upgraded to v6. This is full sw.js:
|
Hmm... we do have a test case for this behavior: workbox/test/workbox-precaching/sw/test-PrecacheStrategy.mjs Lines 105 to 117 in 3151c3a
I'm surprised by what you're seeing. Is there perhaps a 3xx redirect involved here? In other words, you include a URL that doesn't exist in your precache manifest, and then the server responds first with a 3xx response pointing to another URL, and then that other URL results in the 404? Is there any chance you could DM |
@jeffposnick I can share URL, but the problem not reproduce there. I catched this situation when we deploying a new version and some of our server nodes not received specified But I can easy reproduce the problem in test branch by adding unexisting js file path: const precacheUrls = self.__WB_MANIFEST;
if (precacheUrls) {
precacheAndRoute([
...precacheUrls,
{"revision": null, "url": "not-found.js"}
]);
} First installation of service-worker fails, but in Cache Storage I could find Service worker was not successfully installed: But if I refresh the page - the service-worker will be installed successfully and continue to work: After that SW will response from Cache Storage: Is it enough information to reproduce the problem? If not I can try to create separate app to illustrate this behaviour. |
How we build SW:
workbox-config.js`:
|
Also I tried to swap steps of bundling and injecting (I think it's more right way), but it has no effect |
Ah, thank you for sharing all those steps. I believe this is a regression due to some changes in our precaching logic introduced in Workbox v6: workbox/packages/workbox-precaching/src/PrecacheStrategy.ts Lines 142 to 166 in 590d126
That I'll get a fix out for this targeted for the upcoming CC: @philipwalton |
This is now fixed in the v6.1.0 release. |
I am using version v6.2.4 and the error still there |
Hi
Library Affected:
workbox-precache
Browser & Platform:
Google Chrome latest
Issue or Feature Request Description:
Workbox precache module caches 404 error response, but it shouldn't, See screenshot:
Using workbox 6.0.2
My sw.js
The text was updated successfully, but these errors were encountered: