-
Notifications
You must be signed in to change notification settings - Fork 6
Description
After the static routing API is introduced, service worker registrations can be like the following:
self.addEventListener('install', async e => {
await e.registerRouter([
{
condition: { requestMethod: 'GET' },
source: 'cache'
}
]);
self.skipWaiting();
});
// no fetch handlersThis code expects all GET request to refer the service worker cache and does not register any fetch handlers.
However, it seems that the current ServiceWorker spec [1] does not consider the situation where no fetch handlers are registered.
For example, the "Handle Fetch" algorithm of the spec [2] stipulates that:
If the result of running the Should Skip Event algorithm with "fetch" and activeWorker is true, then:
- If shouldSoftUpdate is true, then in parallel run the Soft Update algorithm with registration.
- Return null.
This means that service workers do not work if web developers do not write their own fetch handlers, and at least, the "Should Skip Event" algorithm should be updated.
[1] https://w3c.github.io/ServiceWorker/
[2] https://w3c.github.io/ServiceWorker/#on-fetch-request-algorithm