Offline-First Data Flow
Offline-first PWAs need two paths: read paths that keep the UI useful, and write paths that make retries safe.
Design Rules
| Rule | Why |
|---|
| Render from local data first | Offline and slow networks still feel usable |
| Store writes before sending | You do not lose user work when the network drops |
| Make mutation IDs idempotent | Replays should not duplicate business records |
| Keep queue state visible | Users need to know what is pending, failed, or synced |
| Provide manual retry/export | Background APIs are not universal |
Cache Versus Data
| Need | Use |
|---|
| App shell assets | Precache or versioned Cache Storage |
| Offline fallback page | Cache Storage through service worker fallback |
| API responses safe to reuse | Runtime caching with expiration and invalidation rules |
| User records, drafts, uploads, queue metadata | IndexedDB |
| Conflict resolution state | IndexedDB plus server version metadata |