fix(pwa): network-first navigation so a new deploy loads online immediately #200
Reference in New Issue
Block a user
Delete Branch "feature/sw-fresh-online"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The C1 precache service worker served the precached shell for every navigation — even online — so a new deploy only reached a client after the worker updated its precache in the background (a one-launch lag). A cold online start showed the old version until then; a reinstall forced it fresh (owner-observed on the contour).
Fix
sw.jsno-cache: so the browser reliably detects a new deploy's worker (regression-tested).Why not an explicit version check (the idea we discussed)
The immutable hashed assets already give version-gating — they re-download only when the hash changes. Only the tiny no-cache HTML is re-fetched each online launch. So an explicit version comparison would be redundant (and would need a version scheme the test contour lacks). And there's no reload flash: the fresh shell loads on the initial launch, behind the splash.
Tests
Go: webui (
sw.jsserved as JS +no-cache) — green. UI:check(0), e2e (196),build(generatesdist/sw.jswith the network-first nav), gate 112.8/113.⚠️ Online-launch freshness is contour-verified — the mock e2e disables the SW, so there is no automated test of the worker's navigation strategy. Please deploy this, then deploy any trivial change on top and confirm the second one loads without a reinstall.
Next (the shared-root task): the offline auto-detect (round-1's "network unreachable at cold start → offline after one cycle") + folding
connection.svelteinto a clean offline/slow/online detector.