mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
The offline service worker cached allowlisted GET /api/* reads with stale-while-revalidate, serving the cached pre-mutation copy first and revalidating in the background. Online, a list fetched straight after a create or update rendered the old (or empty) data until the next paint, breaking read-after-write. Switch the data branch to network-first: always fetch fresh from the network online and refresh the cache behind it; fall back to the last cached copy only when the network fails (offline). The offline fallback, the allowlist plus auth/token/secret-body boundary, and the release-versioned cache name are unchanged. Add a regression guard to the cache-policy test that reads public/sw.js and asserts the network-first wiring and the absence of the old stale-while-revalidate handler.