Comparison
Optimistic UIvsRevalidation
Optimistic UI
the item appeared in the list the instant you clicked, before the server had confirmed anything.
Applying the expected result of a mutation locally and reconciling when the response arrives. It removes the network from the perceived interaction, which for a like button or a checkbox is the whole experience. It requires you to write the rollback path too, and to decide what to show when the rollback happens — a state most implementations forget until someone loses work on a flaky connection.
Full entry →Revalidation
the cached data renders instantly and a background request quietly replaces it a moment later.
Serving cached data immediately while fetching a fresh copy behind it, then swapping in the result. It is what makes a data-fetching library feel instant on a second visit, and it is triggered by window focus, reconnect or an interval as well as by navigation. The cost is that users can act on data that is a few seconds old, so anything with a correctness requirement needs an explicit freshness check before the mutation.
Full entry →