- From: Florian Bücklers <notifications@github.com>
- Date: Mon, 23 Nov 2026 23:49:54 -0800
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/ServiceWorker/issues/1690/7125400267@github.com>
fbuecklers left a comment (w3c/ServiceWorker#1690)
We have the same need as @yoavweiss: exclude whole pages (checkout, payment/SSO returns, login) from service worker control — the page and all its subresources, not single requests.
Why sites need this:
- **Script integrity on payment pages.** A worker can serve a changed script under an allowed URL. CSP does not catch that; SRI does, but payment and anti-fraud scripts rarely use it. Requirements like PCI DSS 4.0 6.4.3/11.6.1 make every code path on the payment page part of the audit.
- **Fraud and bot detection.** Any `respondWith()`, even a pass-through, changes what the page observes: `transferSize` 0, encoded size equal to decoded size, empty `nextHopProtocol`, `deliveryType: "cache"`. Anti-fraud scripts read such signals and do not expect a worker in between.
- **Startup on return navigations.** After a payment or SSO provider, the worker has usually stopped. In our field data, 87 % of iOS page views on one payment return had to boot the worker. `workerStart` on an order confirmation was 277 ms at p50 and 948 ms at p90.
- **Blast radius.** Large shops run several parties on one origin and want a guarantee that none of them affects the checkout. A routing rule inside the worker is a setting. Security reviews ask for a platform guarantee.
Static routing can't express this: `/assets/app.js` looks the same on a product page and on the payment page, and a `"network"` route still leaves the page controlled (WICG/service-worker-static-routing-api#7).
We already solve this in production today, in a rather ugly way: for each excluded prefix we register a second, empty service worker without a fetch handler:
```js
navigator.serviceWorker.register('/sw.js', { scope: '/' });
for (const scope of ['/cart', '/checkout', '/login']) {
navigator.serviceWorker.register('/sw.js?empty=1', { scope });
}
```
Longest-match picks the empty worker, so the main worker never sees those pages or their subresources. We run this on several large e-commerce sites, and shop security reviews accept it.
But it is a hack:
- one extra registration per prefix
- prefix-only
- hard to remove
- installed by the third party, not by the site
Proposal: make this a first-class exclusion list on the registration, set by `register({ scope: '/', scopeExclusions: ['/checkout', '/:locale/cart'] })` or by a `Service-Worker-Scope-Exclude` header on the worker script. A matching client is uncontrolled. That is the effect of our empty worker, without a second registration.
Feedback welcome. We're glad to help with spec text and tests.
--
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1690#issuecomment-7125400267
You are receiving this because you are subscribed to this thread.
Message ID: <w3c/ServiceWorker/issues/1690/7125400267@github.com>
Received on Tuesday, 24 November 2026 07:49:59 UTC