From my service worker, I am saving some assets in the browser cache, as well as the service worker script itself, and it works fine so that I can see the service worker url together with all other assets in my devtools cache tab.
Now, when I go offline, my service worker listens to the fetch
event and gets all assets from cache.
However, there seems to be no fetch event when the page tries to register the worker itself, therefore I'm getting the following errors in the console:
console error
console erorr
Am I missing something? After all, does it make sense to cache the service-worker script itself?
From my service worker, I am saving some assets in the browser cache, as well as the service worker script itself, and it works fine so that I can see the service worker url together with all other assets in my devtools cache tab.
Now, when I go offline, my service worker listens to the fetch
event and gets all assets from cache.
However, there seems to be no fetch event when the page tries to register the worker itself, therefore I'm getting the following errors in the console:
console error
console erorr
Am I missing something? After all, does it make sense to cache the service-worker script itself?
Share Improve this question edited Apr 10, 2021 at 21:29 Serge Stroobandt 31.7k9 gold badges121 silver badges109 bronze badges asked Oct 19, 2016 at 22:58 VasChatVasChat 731 silver badge4 bronze badges 3- stackoverflow./questions/39418740/… and stackoverflow./questions/38843970/… both provide some relevant information. – Jeff Posnick Commented Oct 21, 2016 at 20:26
- @JeffPosnick thanks a lot for the tip – VasChat Commented Oct 22, 2016 at 19:29
- Note that if it were possible for a service worker to cache itself, there would be no way to ever update it! – Antimony Commented Nov 4, 2016 at 2:00
1 Answer
Reset to default 10According to the specification of the update algorithm (which is run for registering also). At the point 7.2:
Set request’s skip service worker flag and request’s redirect mode to "error".
That's mean your service worker request will never pass through the service worker. Instead, it is cached in its own cache according to its own rules. What you see as errors, are the failing attempts of the browser to get a fresh version of the service worker.
As Jeff Posnick says in one of his replies, you can safely ignore these errors.