Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip service worker no-op fetch handler #1671

Closed
yoshisatoyanagisawa opened this issue Feb 13, 2023 · 1 comment
Closed

Skip service worker no-op fetch handler #1671

yoshisatoyanagisawa opened this issue Feb 13, 2023 · 1 comment

Comments

@yoshisatoyanagisawa
Copy link
Contributor

Hi Service Worker WG!

Let me ask your feedback on our proposal:

Some sites have a no-op (no operation) fetch handler (e.g. onfetch = () => {}). Since having the fetch handler was one of the requirements to be a progressive web app (PWA), we assume that they did that to make their site recognized as PWA. However, it only brings overheads to start a service worker and execute a no-op handler without bringing any feature benefits like caching or offline capabilities because the code does nothing. To make the navigation to such pages faster, we would like to omit the service worker start and the handler execution from the navigation critical path if a user agent identifies that the service worker fetch handler is no-op.

This is mostly a behind-the-scenes performance improvement. However, it can subtly change the behavior in edge cases, such as dynamically-updated fetch handlers.

Currently, the explainer is in my private repository, but I am happy to move the explainer into this repository if the group is interested in centralizing discussion

@jakearchibald
Copy link
Contributor

I'm happy with this proposal. There's an observable change in behaviour for cases where the fetch listener changes over time (eg with Math.random() or Date.now()), but these cases are somewhat unpredictable anyway, because it depends on the service worker terminating and starting up to pick up the new function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants