diff --git a/public/push-sw.js b/public/push-sw.js index 6cee50c..f0c6b7a 100644 --- a/public/push-sw.js +++ b/public/push-sw.js @@ -10,7 +10,7 @@ * navigations are network-first with an index fallback. No API, DM or model * request is ever stored; only same-origin static bytes. */ -const SHELL_CACHE = 'skate-spots-shell-v2'; +const SHELL_CACHE = 'skate-spots-shell-v3'; const SHELL_ASSETS = ['/', '/index.html']; self.addEventListener('install', (event) => { @@ -39,6 +39,12 @@ self.addEventListener('fetch', (event) => { const url = new URL(request.url); if (url.origin !== self.location.origin) return; if (url.pathname.startsWith('/api/') || url.pathname.startsWith('/.netlify/')) return; + // Never cache the boot guard: an old cached copy must not be able to trap + // the app in its own stale-worker cleanup path. + if (url.pathname === '/boot-guard.js') { + event.respondWith(fetch(request).catch(() => caches.match(request).then((cached) => cached || Response.error()))); + return; + } if (request.mode === 'navigate') { event.respondWith( diff --git a/src/lib/appServiceWorker.ts b/src/lib/appServiceWorker.ts index ec27978..e9f3af8 100644 --- a/src/lib/appServiceWorker.ts +++ b/src/lib/appServiceWorker.ts @@ -29,7 +29,7 @@ export function registerAppServiceWorker(): void { started = true; const register = () => { - navigator.serviceWorker.register('/push-sw.js').catch(() => { + navigator.serviceWorker.register('/push-sw.js', { updateViaCache: 'none' }).catch(() => { // Private mode / unsupported browser — the app works without it. }); };