The invoice save returns success. The billing page reloads and shows the previous total, the previous line items, or a status the user has already changed. The database row holds the new values. The handler that rendered the page served a cache entry stored before the save, and the save left that entry in place.
The commit can land while that entry stays as it was. The update endpoint returned success and often wrote the correct row, and the page keeps rendering the old entry. The latency chart for the read still looks fine, because the hit records a short duration.
The invoice query, or the dashboard aggregate beside it, is a common reason a page waits before the first byte. A cache in front of that read removes the query from the rendering path. The page gets faster because it skips the row, and it stays fast after the row changes while the old entry remains. A TTL removes the entry at expiry. An entry written the previous afternoon and left in place is still yesterday's invoice, and every save since that write has already committed.
The save and the cache write are separate
Cache-aside stores the database result under a key on a miss. The save is expected to delete that key or replace the value. Postgres and Redis commit separately, so the handler can return success after the database commit and treat the cache call as best-effort. If that call errors, times out, or is skipped because the response is already on the wire, the old entry remains. The next read is a hit on the invoice from before the save.
A delete issued before the commit leaves room for a concurrent read to miss, load the pre-commit row, and store it after the delete and after the commit. The delete worked, and the later set put the pre-save invoice back. A queue between the commit and the delete stretches the same interval. The browser has the success response, the consumer has yet to delete the key, and a reload hits the previous entry.
A reader that loaded the invoice before the save can restore the old entry even when the delete runs after the commit. It builds the value, yields while the save deletes the key, and then stores the value it already built. The save's trace shows a successful delete and a correct row. The entry present afterward came from the other request, so the useful log is every set and delete for that key around the save, including sets that started earlier.
Writing the new value during the save survives a failed delete and can still lose on ordering. Two saves can commit in one order and reach Redis in another. The row ends on the later commit and the entry ends on the set that arrived last, so the older save can hold the cache after losing the row. A compare-and-set that writes only when the stored version is older than the row's version keeps the hit aligned with the commit. An unconditional set can return a total the row has already replaced.
The read uses another key
Detail is rarely the only entry. The open-invoice list, the dashboard total, the overdue count, and the PDF each have a key. Deleting invoice:{id} while leaving dashboard:{tenant} in place shows a correct detail page and yesterday's total on the dashboard in the same session. The report names the dashboard. The dashboard key is still there after the detail key is gone.
The delete and the read have to build the same string. A UUID on one path and an integer tenant id on the other, a currency code present only on the read, or a deploy id in only one prefix, produces two keys. The save deletes one string and the read fetches another. Invalidation counters still increment. Log both strings before debugging the row.
Process memory often sits in front of Redis. The handler checks a local map, then Redis, then the database. The save clears Redis and the map in the process that took the save. Other processes keep their maps, and the next request can land on one of them. An empty Redis key leaves the page unchanged until that local entry expires or the process restarts. A deploy makes the maps cold. The failure returns once they fill again on any instance other than the one that handled the save.
The browser can show the old invoice with no Redis lookup. A single-page app keeps the last invoice response in memory and renders the billing page from it after the save has committed. A drop that uses a different key from the read leaves the old response in place. A successful PATCH with no following GET means the browser rendered its stored response and sent no fresh request.
A stored GET, still inside its freshness lifetime, is reused by the browser or a reverse proxy. Some proxies drop it when a PATCH hits the URL. Others keep it until freshness ends. If the origin log has the save and lacks the read, that user's response for that URL was served in front of the application. A proxy that keys an authenticated GET on the URL alone can also return one tenant a body stored for another.
A scheduled job stores a summary row or a summary entry, and the page reads that summary. An invoice saved afterward updates the invoice table and leaves the summary on the previous run. The page follows the job. Deleting invoice:{id} leaves the summary where the job put it.
The row and the entry disagree
On a request that reproduces the stale page, read the row and the entry under the key the handler computed. A new row beside a matching entry means the read served the entry. A missing entry on an old page means the response came from process memory, the browser, a proxy, or a summary. An entry newer than the row means the set and the commit finished in different orders.
A replica that has yet to apply the commit produces the same page with no cache on the path. The primary already has the new row. Check lag before looking at key deletes. The read matches the save when it uses the primary, or when it waits until the replica has the version the save returned.
Put a version on the row and in the entry, a monotonic timestamp or an integer, and log it on the save and the read. A page showing version 14 while the row is at version 15 was assembled from a layer that still holds 14.
Retry the delete until it succeeds, and return success to the client after that. Returning success after a swallowed delete keeps the write metric green and leaves the old invoice on the page. The row is already committed, so a client that retries the save on an error from this path needs the save to be safe to repeat. A dashboard allowed to lag for its whole TTL should keep invoice detail on a different entry. Write that allowance beside the TTL. When detail has to match the save, the next GET from that session carries the version the save returned. A mismatch reads the database, stores the new entry, and returns the row. Other sessions keep the cache. Running that extra read on every request would send every invoice view to the database.
Coalesced misses, stale-while-revalidate, and jittered expiry cover a key that is missing or past its TTL. A cache stampede is many requests missing together and rebuilding. A hit here returns an entry older than the row. On an invoice the user has already edited, the user and the row are both ahead of that entry, and returning it hides the save.
When the cache is added on the rendering path, put the key and the version on the same span as the hit. A short duration means the handler skipped the row. If the committed version is already ahead of the version on the span, the short duration is the stale page.