An optimistic update applies a change locally before the authoritative system confirms it, then synchronizes the change in the background. It hides write latency: the user sees an immediate response even though the backend write is still pending. Unlike prefetching, which hides read latency, this technique lets the application continue working with locally modified data. section 11.3 section 11.1
A shopping cart
When a customer adds an item, the application immediately adds it to a local cart and displays the result. It synchronizes the change with the backend afterward, without blocking further local updates. The immediate display is provisional: synchronization can still encounter an error or conflict. section 11.3 section 11.3.4
An optimistic view combines a local base database with a shadow write queue. The application records modifications in the queue rather than writing directly to the base database, then queries the merged view. Local storage can be an embedded database such as SQLite or an in-memory data structure. section 11.3.1
Figure 11.4 Optimistic views build on a base database and a shadow write queue. In this example, we have a database table of tasks with ID, task, and completion status. The application writes locally to a shadow write queue, which is combined into an optimistic view, shown on the right.
The diagram shows how queued task changes combine with a base table to produce a queryable optimistic view. section 11.3.2
Synchronization propagates queued changes asynchronously, through a centralized server or a peer-to-peer protocol. When multiple clients modify the same data, their changes must be reconciled. Last-writer-wins selects one conflicting update; physical-clock drift can make ordering unreliable, while a logical clock and node ID can provide an ordering and deterministic tiebreaker. section 11.3.2
Plan for the costs of showing unconfirmed state:
- Stale reads: asynchronous propagation provides weaker consistency than centralized updates. Under eventual consistency, clients may take a long time to see each other's writes. section 11.3.3
- Transient failures: retry synchronization without user intervention. Idempotent operations make retries safer because reapplying an operation does not change the result. section 11.3.4
- Conflicts and validation failures: partial application can accept unaffected changes while rejecting problematic ones, but makes consistency across data harder to maintain. section 11.3.4

