Service Worker subresource filter
- Category
- Service Worker
- Type
- New or changed feature
- Status
- No longer pursuing (Chrome No longer pursuing)
- Intent stage
- Removed
Summary
Allows control over what requests are intercepted by Service Worker fetch events. By setting a Service-Worker-Subresource-Filter HTTP header on the document to some string, only requests which contain a fragment containing the value of the header string will be intercepted. When not set, Service Workers will intercept all requests, as normal.
Motivation
Service Worker fetch events are currently all-or-nothing – if a Service Worker with a fetch event is registered, all fetches will be intercepted by it. This makes incremental adoption difficult because it subjects all requests to the overhead introduced by the Service Worker even if it doesn't end up handling the request in any meaningful way. A subresource filter will allow a document to specify what subresources are allowed to be intercepted by the Service Worker. While a robust API that allows for expression of complex conditions for determining which requests are intercepted is desirable, such an API requires significant effort to implement. We’d like to experiment with a simple API first to verify that an API with this functionality will be worthwhile. If the experiment indicates that an API of this nature would be valuable, we will then move forward with implementing the API in a more robust form.
Standards & signals
- Specification: https://github.com/w3c/ServiceWorker/issues/1584
- Firefox: No signal
- Safari: No signal
- Web developers: Positive — Facebook is interested in using this API in multiple web apps if the experiment is successful
- Tracking bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1202160
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=service-worker-subresource-filter
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+Service%20Worker%20subresource%20filter
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=Service%20Worker%20subresource%20filter
- Baseline status: https://webstatus.dev/?q=Service%20Worker%20subresource%20filter
Explainers: https://github.com/w3c/ServiceWorker/issues/1584