- From: Ashley (Scirra) <notifications@github.com>
- Date: Mon, 04 Dec 2017 12:37:14 +0000 (UTC)
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 4 December 2017 12:37:38 UTC
Actually, this is still important to us, and I'd still like to see it happen. I still run in to nightmarish bugs with overlapping SW scopes (https://bugs.chromium.org/p/chromium/issues/detail?id=789220, closed wontfix, but still no idea what's really going on). It'd be great if it could be better supported. Perhaps the simplest solution is to provide an explicit way for a service worker to hand over a fetch to another SW with a longer scope. E.g. suppose the following two SWs are registered: example.com/sw1.js example.com/v2/sw2.js then sw1.js could do something like this in its fetch handler: ```js self.addEventListener("fetch", event => { // Dispatch to sw2.js if under v2/ path if (event.request.url.startsWith("v2/")) return getV2ServiceWorker().handleFetch(event); // ... (optionally test other paths) ... // ... handle fetch using this SW's logic ... }); ``` This provides a simple way to dispatch fetches to other SWs, which helps split a large god-SW in to smaller SWs with limited responsibility. It doesn't sound like it needs to change the existing ways SWs control clients or fetches, it's just a way to use the lowest-level SW as a dispatcher to other SWs. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/ServiceWorker/issues/1085#issuecomment-348950384
Received on Monday, 4 December 2017 12:37:38 UTC