Does it make sense saving a service worker in cache?

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?


According 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.