Skip to content

fix: prevent stale HTML cache causing blank screen#667

Merged
rzueger merged 1 commit intodevelopfrom
fix/pwa-stale-html-cache
Mar 22, 2026
Merged

fix: prevent stale HTML cache causing blank screen#667
rzueger merged 1 commit intodevelopfrom
fix/pwa-stale-html-cache

Conversation

@rzueger
Copy link
Member

@rzueger rzueger commented Mar 22, 2026

Summary

  • The Cache-Control: no-cache header in firebase.json only matched
    /index.html, but the app uses hash history so the browser only ever
    requests /. Firebase served / with the default max-age=3600,
    letting the browser cache the HTML for up to 1 hour. After a new
    deployment the cached HTML referenced a bundle hash that no longer
    existed, causing SyntaxError: Unexpected token '<' and a blank screen.

  • Verified: the live response for / had Cache-Control: max-age=3600.

  • Add no-cache for / in firebase.json so the browser always fetches
    fresh HTML.

  • Add NetworkFirst runtime caching for navigation requests in the service
    worker as defense-in-depth and offline fallback.

Test plan

  • npm test — 1686 tests pass
  • npm run typecheck — clean
  • npm run build:prod — service worker output verified
  • Deploy and confirm / response has Cache-Control: no-cache
  • Open PWA after deployment — no blank screen

The Cache-Control: no-cache header in firebase.json only matched
requests for /index.html, but the app uses hash history so the
browser only requests /. Firebase served / with max-age=3600,
causing the browser to cache HTML for up to 1 hour. After a new
deployment the cached HTML referenced a bundle hash that no
longer existed on the server, resulting in SyntaxError and a
blank screen.

Add no-cache header for / in firebase.json and add NetworkFirst
strategy for navigation requests in the service worker.
@rzueger rzueger merged commit 728dd2a into develop Mar 22, 2026
2 checks passed
@rzueger rzueger deleted the fix/pwa-stale-html-cache branch March 22, 2026 10:58
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