How to prevent hard reboots from bypassing the worker?

A hard reset or a hard update (like rebooting overload in Chrome, for example) seems to get around the worker.

For example, loading a page with a monitored service, for example https://airhorner.com/ or https://wiki-offline.jakearchibald.com/ , setting the network offline in devtools, and then hard reloading the page will result in a broken page "no Internet connection. " (Regular reloads show the cached page as expected.)

Is there a way to prevent this or use an employee as a backup in case the device is offline?

+4
source share
1 answer

This behavior is explicitly called as part of the working agent specification:

navigator.serviceWorker.controller returns null if the request is a forced update (shift + refresh). ServiceWorker objects returned from this getter attribute, which are the same objects.

So this is not just a browser implementation detail.

If it seemed to you that there is a strong reason why the service worker should not behave this way, the best approach would be to identify your problems in spec problem tracking .

+7
source

All Articles