# 51 — Offline shell + service worker caching ## Goal The app shell loads without network; cached data is shown with a "stale" indicator while fresh data loads. ## Depends on - 50 ## Scope - Service worker uses Workbox-style strategies (hand-rolled, see task 50 rationale): - **App shell** (HTML, JS, CSS): stale-while-revalidate. - **API GETs**: network-first with 2s timeout, fall back to cache. - **Mutations**: never cache; if offline, show a clear "you're offline" toast. - Offline page for navigations that have no cache. - Version SW on every build; show a "new version available, refresh" toast when a new SW takes control. ## Out of scope - Background sync of queued mutations (defer; usually more trouble than worth at this scale). ## Acceptance criteria - [ ] In Chrome DevTools "Offline", reloading the app shows the cached dashboard with a stale-indicator. - [ ] Attempting to mutate while offline shows a clear error, doesn't silently drop. - [ ] Deploying a new build prompts active sessions to refresh.