skip to content

As frontend lead for a team wiki whose editors want to keep working offline for days, would you make the page editor local-first, and who carries the costs?

level: principalimportance: nice to knowfreq 24%

answer

  1. offline length is a product promise
  2. browser storage is best-effort
  3. stored replicas outlive releases
  4. access still checked at sync
  5. server as peer, still the gatekeeper

basics

~20 s

Go local-first only for pages a user opens or marks, with a stated offline limit. Storage can be evicted, stored replicas must survive releases and revoked access must be enforced, so frontend, backend, security and product each own a share.

solid answer

~50 s

I'd choose bounded local-first: replicas for pages a user opened recently or marked for offline, editable offline up to a stated limit, not every page indefinitely. The merge can handle days offline; the cost is everything around it. Browser storage is best-effort and can be evicted, and a persistence request may be refused, so unsynced edits are shown and synced first — the frontend's job. Stored replicas and pending operations outlive releases, so format changes need migrations — frontend and backend together. The server must keep operations as long as the offline promise and still enforce access revoked while a laptop was away — the backend's job, with security signing off on page content stored on laptops. Product owns the limit itself, as one number used by the copy, the retention policy and the client's warning. The server stays as gatekeeper and peer, just off the critical path.

go deeper

for a junior

Recall that local-first means the document lives in the browser and syncs later, so the page keeps working without a network.

for a middle

Explain what a replica needs: storage that can be evicted, one writer across tabs, and pending edits synced first when the connection returns.

for a senior

Name the failure paths — eviction, a stale replica format after a release, revoked access, an absence longer than retention — and the UX for each.

for a principal

Make the call with owners: set the offline limit as one number, assign replica, retention, security and support costs to teams, and say what evidence would reverse it.

## What local-first would mean here **Local-first** means the page's document lives in the browser as a full **replica**: edits apply to local storage first, the page works with no network, and changes sync with the server and other editors whenever a connection exists. The server stops being the place every edit must reach and becomes a peer that stores, forwards and checks access — still essential, no longer on the critical path. For a **team wiki** whose editors want days offline, the question is not whether the merge can cope (a sequence CRDT can) but whether the product will carry everything a replica brings with it. ## Three positions | Option | What users get | What it costs | |---|---|---| | Online editor with a short buffer | edits survive drops of seconds to minutes; offline is read-only | little engineering; frustrates people who edit on trains | | Bounded local-first | chosen pages editable offline up to a stated limit | replica storage, migrations, retention, UX at the limit | | Full local-first | every visible page stored and editable indefinitely | all of the above at full scale, and no natural limit on retention | ## Costs and who carries them - **Browser storage is best-effort by default.** The browser may evict an origin's data under storage pressure, deleting all of it at once; `navigator.storage.persist()` asks for persistent mode, and the browser may or may not honour it; one engine deletes script-written storage for sites the user has not interacted with in the last seven days of browser use, when its tracking prevention is on. Unsynced edits are therefore not safe until the server has them. *Frontend*: show "N changes not yet synced", sync them first on reconnect, request persistence when the user turns offline on. - **Several tabs, one replica.** Two tabs of one page must not both write the stored replica or both sync it; the one-syncing-tab pattern from the offline caching question applies unchanged. *Frontend.* - **Stored replicas outlive releases.** A laptop may return with a replica and pending operations written by a release from weeks ago, so every format change needs a migration or a reader for the old format. *Frontend and backend jointly*, as part of the contract. - **Retention must match the promise.** The server keeps operations long enough for the longest promised offline period, and the "too old" path covers the rest. *Backend*, with the number set by product. - **Data at rest and access.** Page content sits on laptops, shared ones included; sign-out must wipe it (the offline caching question owns the wipe), and access revoked while a laptop was away must still be enforced at sync: the server re-checks and refuses. *Security signs off; backend enforces.* - **Memory and load.** Replicas carry history; snapshots keep them bounded. *Frontend and backend.* - **Support.** "Where did my offline edits go?" tickets will come; a visible sync state and a recovery panel keep them answerable. *Product and support.* ## The call 1. Choose **bounded local-first**: replicas for pages the user opened recently or marked for offline, editable offline up to a stated limit, say two weeks. 2. Make the **limit one number** used by the product copy, the server's retention and the client's warning ("Reconnect within 3 days to keep merging automatically"). 3. Keep the server as **gatekeeper**: access checks, search indexing, notifications and snapshots run there. 4. Write the ownership down: frontend owns the replica and its migrations, backend owns retention and enforcement, security approves stored content, product owns the promise. 5. Revisit with evidence: if few people edit offline, shrink to the short buffer; if many need whole spaces offline, grow toward full local-first with the budget that implies. The evidence is cheap to collect: the share of edits made offline, how long laptops stay away, how often clients find their stored replica gone, and tickets about lost edits. ## What not to conclude Local-first does not remove the server — peers that are not online at the same moment cannot exchange edits without something that stores and forwards. It does not make browser storage durable, and it does not make collisions disappear, so the collision UX is still needed. It moves work from the network path into the client and asks several teams to keep one promise together.

  • What if storage is evicted while edits are still unsynced?
    They are gone from that browser — eviction removes the origin's data all at once — so shrink the window in which that can happen: sync as soon as any connection exists, show the unsynced count, and request persistent storage when offline mode is turned on, knowing the browser may refuse.
  • Why not drop the server and sync peer to peer?
    Peers must be online at the same time to exchange edits, and a wiki needs access control, search, notifications and a durable copy that no single laptop provides. Keep the server as a peer that stores and forwards; it simply stops sitting in every edit's path.

  • Data in IndexedDB stays until the user clears it, so offline edits are safe.
  • Going local-first means the product can retire its server.
  • Stored replicas never need migrating; the next release will read them as they are.
  • Offline edits from a user whose access was revoked should still merge on sync.
  • Make every page the user can see editable offline indefinitely, at no extra cost.