Skip to content

Purge the web cache after the write commits, not inside it - #276

Merged
jadhavgaurav merged 1 commit into
mainfrom
development
Sep 22, 2026
Merged

jadhavgaurav merged 1 commit into
mainfrom
development

Conversation

@jadhavgaurav

Copy link
Copy Markdown
Contributor

Publishing the Kubernetes whitepaper left its page a 404 for the full ISR window and kept the new card off /resource-center. Purging the same paths by hand a few minutes later worked in 15 seconds.

Root cause

Payload runs afterChange, afterDelete and even afterOperation hooks inside the write transaction; commitTransaction is the last thing the operation does. The purge therefore reached apps/web while the write was still invisible to every other connection, so Next re-rendered against the pre-write database and Vercel cached that result: a 404 for a page being published, the old content for an edit.

This affects every publish, not just this one.

Checked and refuted first

  • The listing-path override (resources to /resource-center) was already correct and deployed.
  • WEB_REVALIDATE_SUPPRESS is unset on the droplet.
  • The Teams webhook 400 raised during the same save did not abort the hook chain: both webhooks-publish and indexnow-publish swallow their own errors.

The fix

revalidateWebAfterCommit schedules the purge past the commit and does not make the save wait for it, because a hook must not block a save on cache invalidation. Hooks pass req.transactionID; with no transaction open the helper behaves exactly like revalidateWeb, so the cache-purge endpoint and one-shot scripts are unchanged.

Incident written up in docs/operations/INCIDENTS.md.

Verifying after deploy

Publish or edit any document and watch its listing without purging by hand. The page should turn over within a few seconds.

checks: cms lint, typecheck, build, 2037 tests

Payload runs afterChange, afterDelete and afterOperation hooks inside the
write transaction, so a purge sent from one reached apps/web while the
write was still invisible to every other connection. Next re-rendered
against the pre-write database and cached that: a 404 for a page being
published, the old content for an edit.

The Kubernetes whitepaper published on 2026-09-22 stayed a 404 for its
whole ISR window this way, and its listing kept the old cards until
someone purged by hand.

revalidateWebAfterCommit schedules the purge past the commit and does
not make the save wait for it. With no transaction open it behaves
exactly as before, so the cache-purge endpoint and one-shot scripts are
unchanged.
@jadhavgaurav
jadhavgaurav merged commit 094ce2b into main Sep 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant