Offline-first workflows: make synchronization explicit
A practical model for durable local actions, outbox states, safe retries, and conflicts when a device reconnects.
Key ideas
- Persist local actions and outbox entries together.
- Keep event identity stable across network retries.
- Make server decisions and synchronization status visible.
On this page
A local write and a server decision are different events
An offline interface can accept work before the server knows it exists. A student may answer a practice question, a field worker may edit a record, or a user may save a draft while their connection is unstable. The application needs to show what has been saved locally and what has been accepted remotely.
My IFAA ENTRANCE work spans web and mobile codebases, including a Flutter companion with local SQLite persistence. That context makes synchronization an application-design problem: the user experience depends on how state survives interruption and reconnects with server-owned rules.
The example here is a practice response. Timed assessments need their own explicit rules for deadlines, offline participation, and authoritative scoring.
Give each local action a durable identity
A practice response can carry a client-generated event identifier:
{
"eventId": "practice-event-123",
"sessionId": "session-456",
"questionId": "question-789",
"selectedOption": "B",
"contentVersion": 4
}
The identifier represents one user action. Persist it with the action instead of generating a different identifier for every network attempt. Otherwise a retry looks like new work to the server.
The server should derive the user from the authenticated session, validate ownership and question membership, and decide what it accepts. A client-generated identifier is useful for deduplication; it is not proof that the action is legitimate.
Commit the local change and the outbox together
An outbox is a durable list of actions waiting to synchronize. When a user answers, save the local response and its outbox entry in the same local database transaction. This avoids a response that appears saved but is never scheduled for upload.
Use explicit states such as:
- Queued: saved on the device and waiting to send.
- Sending: a synchronization attempt is in progress.
- Confirmed: the server has acknowledged the action.
- Needs attention: the server rejected it or a conflict needs user input.
If the app closes while an action is sending, a later run needs a recovery rule. Persisting an in-flight state without recovery can strand work indefinitely.
Treat an ambiguous timeout as unknown
A request can reach the server even when the response never reaches the device. Retrying after a timeout is therefore expected behavior.
The server needs a durable uniqueness rule for the event within the appropriate user and operation scope. It should return the previous result for an equivalent retry and reject reuse of the identifier for different input. Two concurrent deliveries should produce the same logical result as one delivery.
Client timestamps can help explain what a user saw. They should not, by themselves, decide deadlines, authorization, or grading. Device clocks can be wrong.
Define conflicts before they happen
A question may change while a device is offline. A session may close, permissions may change, or the same account may continue on another device. A synchronization design needs a response for each of those situations.
A content version helps the server detect that the action refers to an older view. The product then needs a deliberate policy: accept the compatible change, ask the user to refresh, or explain why the action cannot be applied. Silently replacing server state can hide a real disagreement.
Keep account boundaries explicit on shared devices. Data saved for one account must not be uploaded as another account after sign-in changes.
Make synchronization visible without making it noisy
Use plain status language: “Saved on this device,” “Waiting to sync,” or “Sync complete.” Keep the user's work available when a retry fails. A small persistent status is often more useful than repeated error notifications during a known connection outage.
Test reconnects, duplicate delivery, app restarts, revoked access, stale content, and account changes. Include the case where the server accepts an action but its acknowledgement is lost.
Offline support becomes dependable when local persistence, synchronization, and server rules form one explainable workflow.