Cross-cutting concerns (the O in RADIO) · senior
Offline-first and sync
Offline-first means the app reads and writes a local store first, queues every change in an outbox with an idempotency key, syncs in the background with a clear conflict rule, and shows the user what is saved and what is pending.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Layers: a service worker caches the app shell (cache-first) and some GET data (network-first or stale-while-revalidate); IndexedDB (SQLite on mobile, WASM SQLite + OPFS on the web like Notion) holds the data.
- Outbox: each write gets a client id and idempotency key, is saved locally first, then a single flusher sends in order, retries with backoff, and removes it on ack.
- Sync down: delta sync with a server cursor ('changes since X'); tombstones for deletes.
- Conflicts: last-writer-wins per field (Figma does this per property with the server ordering events), server-side merge, version/ETag with 409 on conflict, or CRDTs for collaborative text.
- The Background Sync API is not Baseline (Chromium-only); also sync on app start, on the 'online' event and on focus. Mobile OSes limit background work.
- UX: offline banner, per-item 'pending/failed' status, 'last synced' time; block actions that cannot work offline (payments).
- Storage: ask navigator.storage.persist(), handle quota errors, encrypt sensitive data on mobile.
- Many tabs: let one tab own the database (Web Locks or a SharedWorker, as Notion does) and notify others with BroadcastChannel.
The red pen
Common traps: mistake → fix
Mistake: navigator.onLine === true means the internet works
Fix: it only means a network interface exists; confirm with a request.
Mistake: Background Sync works everywhere
Fix: only in Chromium browsers.
Mistake: Retrying a POST is safe
Fix: without an idempotency key it can create duplicates.
Mistake: Last-write-wins is fine for everything
Fix: it loses edits in shared text.
Easy to hard
Questions interviewers ask, easy to hard
- How would you make a notes app work offline?
- The user edits the same note on phone and laptop while offline. What happens on reconnect?
- How do you make sure a queued 'send' doesn't happen twice?
- What does the user see while changes are pending?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.