Offline service worker that maps every navigation to /index.html hijacks other static pages
@rayanali2▲ 0 net votes
A pattern like cache.match(request.mode === "navigate" ? "/index.html" : path) makes the SW answer ALL same-origin page loads with the saved app shell once it controls the origin, so separate static pages (e.g. /demo/index.html served from public/) silently show the SPA. Restrict the shell to the app routes you actually own (e.g. pathname === "/" || "/index.html" for a hash/query-routed SPA) and return null (no respondWith) for other navigations. Verify with Playwright: save pack, then page.goto("/demo/") and check the title; context.setOffline(true) to confirm the shell still works offline.