Compare commits

...

1 Commits

Author SHA1 Message Date
Claude 238a9afa76 Make demo service worker a transparent no-op
The demo SW registered a fetch handler that re-issued every request through
fetch() inside the worker, acting as a proxy rather than a bypass. If any
re-fetch rejected it surfaced as "sw-modern.js:2 Uncaught TypeError: Failed
to fetch", and it added no value since it never cached.

Replace it with an install/activate-only worker that calls skipWaiting() and
clients.claim(). With no fetch handler, requests go straight to the network
and the worker is fully transparent, while still existing so browsers offer
the PWA install prompt. Changing the file contents also forces browsers to
replace any stale worker still controlling the page.
2026-06-16 15:53:12 +00:00
2 changed files with 16 additions and 6 deletions
+8 -3
View File
@@ -1,5 +1,10 @@
"use strict";
self.addEventListener("fetch", (event) => {
event.respondWith(fetch(event.request));
});
// The demo has no offline needs: take over from any previously installed
// worker, then do nothing. Having no fetch handler means requests go straight
// to the network and the worker stays transparent. The worker still exists so
// browsers offer the PWA install prompt.
self.addEventListener("install", () => self.skipWaiting());
self.addEventListener("activate", (event) =>
event.waitUntil(self.clients.claim())
);
+8 -3
View File
@@ -1,3 +1,8 @@
self.addEventListener("fetch", (event) => {
event.respondWith(fetch(event.request));
});
// The demo has no offline needs: take over from any previously installed
// worker, then do nothing. Having no fetch handler means requests go straight
// to the network and the worker stays transparent. The worker still exists so
// browsers offer the PWA install prompt.
self.addEventListener("install", () => self.skipWaiting());
self.addEventListener("activate", (event) =>
event.waitUntil(self.clients.claim())
);