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

RuleWhy
Render from local data firstOffline and slow networks still feel usable
Store writes before sendingYou do not lose user work when the network drops
Make mutation IDs idempotentReplays should not duplicate business records
Keep queue state visibleUsers need to know what is pending, failed, or synced
Provide manual retry/exportBackground APIs are not universal

Cache Versus Data

NeedUse
App shell assetsPrecache or versioned Cache Storage
Offline fallback pageCache Storage through service worker fallback
API responses safe to reuseRuntime caching with expiration and invalidation rules
User records, drafts, uploads, queue metadataIndexedDB
Conflict resolution stateIndexedDB plus server version metadata