Re: [ServiceWorker] Proposal: Optimized No-Fetch Service Workers (#718)

With this proposal, it's impossible to use ServiceWorker for other tasks and just forget about caching (while keeping good performance). You have to do one of these two things:

* Properly implement the `fetch` event (with caching, full offline capabilities, or whatever).
* Call `disableFetch()` so the browser knows it can go straight to the network without firing a `fetch` event first.

Personally, I dislike the opt-out nature of this proposal. It's too easy to forget if you don't want to use offline capabilities, and adds more boilerplate code. It's also counter-intuitive to me.

Many other capabilities have been mentioned for service workers, that are not dependent on offline capabilities, like push notifications, background sync, and geolocations. We don't know yet where service workers will actually be used for in 5 years.

Additional reasons why I think opt-out is a bad idea:

* It isn't currently visible that there is a performance problem when forgetting `disableFetch()` in applications that don't care about offline capabilities. Maybe browsers will eventually have to implement some form of `fetch` event detection for badly written service workers. Though with `disableFetch()` I think it's a good idea to throw a warning in the developer console if no `fetch` handlers are registered when `disableFetch()` has not been called by the end of the `install` event.
* Some applications are inherently dependent on the network. A feature like background sync can't work without network access.

Note that, again, service workers are very new so everyone using them now should expect things can break with every new browser release. Consider [ServiceWorkerMessageEvent](https://www.chromestatus.com/feature/5163630974730240) which suddenly moves from `window` to `navigator.serviceWorker` (offtopic: good move!). Now displaying warnings about how the `fetch` event is going to change in a few versions and requiring to opt-in to the events doesn't seem like a big problem to me. The longer you wait with such changes, the harder it is to change.

(This is my opinion on the matter, as someone who doesn't (yet) work professionally as web developer.)

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/718#issuecomment-124854122

Received on Saturday, 25 July 2015 15:45:22 UTC