For a heavily interactive application like a workflow system, no network means no work. Field engineers operating in workshops or warehouses — places with spotty signal — can lose connectivity at any moment. So offline capability is a hard requirement, not a nice-to-have.
Overall Architecture
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
┌─────────────────────────────────────┐ │ ServiceWorker │ │ (offline asset cache + request │ │ interception) │ ├─────────────────────────────────────┤ │ In-MemoryState (Pinia) │ │ - current work order list │ │ - user action queue │ ├─────────────────────────────────────┤ │ PersistenceLayer (IndexedDB) │ │ - work order data cache │ │ - pending action queue │ ├─────────────────────────────────────┤ │ NetworkStatusDetection │ │ - navigator.onLine │ │ - heartbeat probe (WebSocket ping)│ └─────────────────────────────────────┘
IndexedDB Cache Design
We use the idb library to simplify IndexedDB operations:
IndexedDB transaction timeouts — too many puts in one batch would hang. Switched to batched writes, 50 at a time
Queue conflicts — modifying the same record twice while offline meant the replay order got scrambled. Added a version field for conflict detection
Service Worker cache strategy — STALE_WHILE_REVALIDATE fits best: show stale data first, then silently update
Results
After shipping this scheme, the reconnection success rate after dropouts climbed from 60% to 98%+, and users in weak-network environments basically never feel an interruption.