PWA and Service Worker
Cashlytics registers its service worker only in production.
Registration
src/components/pwa/service-worker-registrar.tsx registers /sw.js with scope / in production. In development, it unregisters existing service workers and removes Cashlytics caches to avoid stale local behavior.
Cache Strategy
public/sw.js uses:
- cache-first for
/_next/static/assets - network-first with a 10 second timeout and 5 minute max-age fallback for
/api/GET requests - network-first for pages, falling back to
/~offline
The offline page is pre-cached during service worker install along with favicon and manifest assets.
Push Events
The same service worker handles push and notificationclick. Push payloads can include title, body, icon, badge, and url. Notification clicks focus an existing same-origin app window when possible or open a new one.