Most web applications are built on a quiet assumption: the network is there. A request goes out, a response comes back, and the interface updates. While that assumption holds, nothing looks wrong. When it stops holding, the application usually stops being useful at all.
What actually happens when the connection drops
Connections fail in more ways than simply being offline. A phone moves between networks. A laptop wakes from sleep with a stale session. A server restarts. A request times out halfway through. From the user's side these all look the same: they pressed a button and nothing they can see happened.
Many applications answer this with a spinner that never resolves, an error message that disappears, or a change that is silently lost. The user cannot tell whether their work was saved, and that uncertainty is the real cost.
Three principles worth designing around
- Keep a local copy of the data the user needs, so the interface can render without waiting on the server.
- Treat a write as something that must eventually reach the server, not something that either succeeds right now or is gone. Queue it locally and send it when a connection returns.
- Never lose a change quietly. If a queued write ultimately fails, keep it and show it to the user with a way to retry or discard it.
Local data first
Reading from local storage first makes the interface fast and independent of the connection. The server remains the source of truth, and the local copy is a working cache that refreshes whenever it can. The interface should say plainly when it is showing data that may be out of date, rather than pretending nothing is wrong.
Queue writes, and replay them carefully
A write queue is simple in concept and easy to get wrong. If a request succeeds but the response is lost, replaying it sends the same change twice, so writes need to be safe to repeat. Order matters too: two edits to the same record must be applied in the order the user made them.
Make failure visible
A queue that quietly drops what it cannot send is worse than no queue. Failed writes belong in a visible place, with an explanation and a choice: try again, or discard. That keeps the user in control and keeps the data honest.
Not every application needs this
Offline support has a cost in complexity. A dashboard that is only useful with live data may be better off showing a clear message that the server cannot be reached. The useful question is what a person needs to be able to do while the server is briefly unavailable, and the design should follow from that answer.
This is the thinking behind much of our work on Flux, our own data infrastructure. The principles apply to any web application, whatever it is built on.