The concept
No signal in a basement, yet a payment must be recorded. An offline-first app saves each change on the phone first, and sends it once a network returns.
Offline-first is a way to build an app so that it works without a network: it reads and writes its own copy of the data on the device, and syncs that copy with a server when a network is there. Android's guide to offline-first apps makes the local database the app's source of truth: screens read only from it, and the network only ever updates it.
A change made offline is written to the local database first and queued to be sent later, what the guide calls a lazy write. Here the queue is an outbox: a table in the same database, written in the same transaction as the change, so the two never disagree, and kept on disk, because the system can stop a background app's process at any time to reclaim memory. The system's scheduler, WorkManager on Android, runs the sync once a network is connected, even after the app was closed, and tries again with exponential backoff when it fails.
A network can drop after the server has applied a change but before its answer arrives. The phone cannot tell, so it sends the change again: a change may arrive more than once. A unique ID made on the phone and sent with each change, as in the IETF's Idempotency-Key draft, lets the server recognise a repeat and answer it without applying it twice.
While the phone is offline, someone else can change the same data on the server. Android's guide names last write wins as a common approach on mobile: each change carries the time it was made, and the server keeps the newer, silently discarding the other. Applying changes in the order they arrive is a different rule, and a worse one: a change made offline arrives late and erases newer work. Sending the version a change started from, with HTTP's If-Match, lets the server refuse a change made against an old version, so the conflict is seen and settled instead of lost.
Local-first software, as Kleppmann and his co-authors described it in 2019, goes further: the copy on the device is the primary one, and concurrent changes merge by themselves with CRDTs. This machine shows the simpler and more common form, where the server holds the copy every phone shares. The 60 ms each way and the time spent offline are modelled.