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 

> Can I ask why avoiding writing code like above is important?
> Do you have a specific request from your users, are there statistics, or anything else?

I'd like to clarify my position to avoid misunderstanding, I'm a volunteer contributor but not an paid developer from some browser vendors. I commented here with a hat of web developer.

---

> I am sorry, I failed to catch the point. The install event must happen before the fetch event, and regardless of addRoutes() is called or not, the fetch event will come (or may not come) after.
Will you rephrase this?

What I wanted to say is that, if the spec defines the fetch event occurs only after the install event, we may have a chance to switch the running mode  for UA's optimization as the motivation in the case that an developer calls `event.addRoutes()`. In other words, I'd like to say [in this issue](https://github.com/w3c/ServiceWorker/issues/1712#issue-2194493473) that we may be able change a internal mode related to firing `fetch` event and `"network"` in [`RouterSourceEnum`](https://w3c.github.io/ServiceWorker/#enumdef-routersourceenum) maybe unnecessary (as a exposed API for developer).

---

> Again, can I ask why reducing the application code is so important?

Simply, I feel the current proposal is a bit complex as a developer exposed API and I filed this issue.

As my understanding through I read https://github.com/WICG/service-worker-static-routing-api and your comment, the original motivation of it is that introduce the capability to skip some the registered fetch handler, isn't it?

I think there're mixed API semantics both opt-in behavior and opt-out behavior that may confuse a developer as illustrate sample codes in https://github.com/w3c/ServiceWorker/issues/1712#issue-2194493473. If the goal of https://github.com/WICG/service-worker-static-routing-api is to reduce the intercepting by service worker, can we move mental model to the opt-in invokation for the fetch handler on calling `InstallEvent.addRoutes()`?

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

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

Received on Tuesday, 18 February 2025 10:01:05 UTC