Re: [w3c/ServiceWorker] Can we make to avoid to invoke ServiceWorker _by default_ for if user code call `event.addRoutes(rules)` in `install` event handler? (Issue #1712)

tetsuharuohzeki left a comment (w3c/ServiceWorker#1712)

@yoshisatoyanagisawa 

>  If you want to completely skip the fetch handler, you can explicitly add a rule to catch all to go to "network" before the default route.

My intention of this proposal is that a developer can skip to write such thing.

I think we have a optimization chance and I guess this not might cause a destructive behavior change.

First, I think that we can regard as that calling  `InstallEvent.addRoutes()` is an developer’s sign for optimization for an user agent.  On a user agenet that does not support it, an user application will not call it. It would not a violate an exist code even if `InstallEvent.addRoutes()`  introduce a new internal concept that allows some optimizations. And this assmption would not be against to the original motivation of https://github.com/w3c/ServiceWorker/pull/1701, I think.

Second, an application can call `InstallEvent.addRoutes()` only in `install` event handler. `fetch` event would a wait to complete `install`. There are lifecycle order. If an application did call  `InstallEvent.addRoutes()`,  user agent can fire`fetch` event under this proposal’s assumption. On the contrary,  if an application does not call `InstallEvent.addRoutes()`, user agent should fire `fetch` event with the traditional manner.

Third, I think this proposal can reduce a application code with the achievement of static routing API’s motivation.

Eventually,

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1712#issuecomment-2663588738
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/ServiceWorker/issues/1712/2663588738@github.com>

Received on Monday, 17 February 2025 16:28:15 UTC