Skip to content

fix: SW reload bypasses old runtime HTML cache on post-update reload - #458

Merged
ciotlosm merged 1 commit into
mainfrom
fix/version-check-ticker-and-sw
Jul 23, 2026
Merged

fix: SW reload bypasses old runtime HTML cache on post-update reload#458
ciotlosm merged 1 commit into
mainfrom
fix/version-check-ticker-and-sw

Conversation

@ciotlosm

Copy link
Copy Markdown
Member

Summary

The update banner sometimes persists until a full app kill because the SW
reload path serves stale HTML from the OLD SW's runtime HTML cache.

Root cause

When a new version drops, the old sequence was:

  1. SW calls skipWaiting() + clients.claim()
  2. Browser reloads the page — OLD SW intercepts (still active during handoff)
  3. OLD SW's navigation handler: serve from runtime-html-vOLD-v1 cache first
  4. Page boots with OLD HTML → old app bundle → CHECK_VERSION sees matching
    versions → no further reload → banner persists

Fix

SW no longer calls skipWaiting + clients.claim() directly. Instead it sends
a RELOAD_APP message to the app with a timestamp. The app calls
location.reload('?__sw_reload=<timestamp>'). The OLD SW's navigation
handler detects the param, bypasses its own runtime HTML cache, and fetches
fresh HTML from the network. The new SW then caches the fresh HTML in its
own bucket on subsequent navigations.

The ?__sw_reload param is stripped before storing, so subsequent
navigations hit the normal stale-while-revalidate path.

Offline safety: if the network is down on the post-update reload, the
handler falls back to the precache (always has /index.html from install).

SW no longer calls skipWaiting + clients.claim directly. Instead it sends
a RELOAD_APP message to the app, which calls location.reload with a
__sw_reload=<timestamp> query param. The OLD SW's navigation handler
detects the param, bypasses its own runtime-html cache, and fetches fresh
HTML from the network. The new SW then caches the fresh HTML in its own
bucket on subsequent navigations.

Why this matters: skipWaiting + clients.claim() triggers an automatic
reload controlled by the OLD SW's fetch handler, which serves from the
old runtime-html cache first (stale-while-revalidate). The stale HTML
boots the old app bundle, CHECK_VERSION sees matching versions, no
further reload fires, and the update banner persists until the user
fully kills the app.
@ciotlosm
ciotlosm force-pushed the fix/version-check-ticker-and-sw branch from 46ef5f0 to 332fe4b Compare July 22, 2026 21:04
@ciotlosm
ciotlosm merged commit 2006f1b into main Jul 23, 2026
6 checks passed
@ciotlosm
ciotlosm deleted the fix/version-check-ticker-and-sw branch July 23, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant