Slow networks + PWA launch: cache-first item images, per-user SW caches, dashboard start_url, loading skeletons

Merged
FR
6d ago
+600-21

What & why

First slice of slow-network / mobile PWA improvements.

  • Item images cache-first. The /api/ NetworkFirst rule matched the image proxy before the image rule, so every tile waited on the network (up to 10s) before using its cached copy. /api/v1/images/* (immutable random-UUID keys) now goes CacheFirst, 200s only. Runtime caches get expiration; no-store responses (map image) are kept out of Cache Storage.
  • SW caches tied to their owner. Page/API/image caches outlived sign-out and could serve the last user's data as a slow-network fallback. SessionStateReset now records the cache owner in localStorage and clears user-scoped caches on sign-out or when a different user hydrates (deny-by-default: only precache + static build caches survive).
  • Installed app launches into /dashboard. start_url: "/" cost every launch a redirect round trip. id pinned to "/" so existing installs keep their identity. 180px opaque apple-touch-icon.
  • loading.tsx for dashboard + rooms so taps on a slow network get immediate feedback.

Checklist

  • User-facing change → added/updated a PostHog event, or N/A — N/A (perf/caching; install analytics come in the next slice)
  • User-facing or service change → docs updated, or N/A — N/A
  • New error paths report via captureServerException / the error boundary, or N/A — N/A (cache clearing is best-effort, swallowed)
  • New behavior is covered by tests, or N/A — sw-caches.test.ts, session-caches.test.ts, session-state-reset.test.tsx, manifest.test.ts
  • If this fixes a recurring defect, considered a guardrail via the learn skill, or N/A — N/A

Notes

  • Touches client sign-out cleanup (not server auth logic) — worth a look.
  • Verified: prod build emits the new rules in sw.js; skeletons screenshotted (mobile dark, desktop light). Not tested on a real device or throttled network.
  • Known gaps / follow-ups: layout auth round trips still gate TTFB; iOS startup images and theme-aware splash not done.

Generated by Claude Code