Skip to content

fix(cms): revalidate every locale when a page or post is published, unpublished or deleted - #219

Merged
dogfrogfog merged 1 commit into
mainfrom
fix/cms-revalidate-all-locales
Oct 28, 2026
Merged

dogfrogfog merged 1 commit into
mainfrom
fix/cms-revalidate-all-locales

Conversation

@dogfrogfog

Copy link
Copy Markdown
Member

Problem

Page.\_status is not localized, but the page and post revalidation hooks invalidated only the locale from the request (?locale=, default en).
After deleting or unpublishing a document, its other locales stayed in the Next data cache.

Observed on the live site: after a test page was deleted with a REST DELETE (no ?locale), /test-hero-check returned 404 but /es/test-hero-check kept returning 200 with the deleted content.
A delete from the admin panel has the same problem, because the request carries only the current locale.

Fix

  • Publish, unpublish and delete now invalidate the cache tags of every locale (ALL_LOCALES, from I18N_CONFIG).
  • A content edit of an already published document still invalidates only the edited locale.
  • revalidatePageCache takes locales instead of one locale. The Header, Footer and Global Block callers pass [locale], so their behaviour does not change.
  • Same change for posts, which used the same pattern.

Verified

  • New tests/int/revalidatePage.int.spec.ts (4 tests): delete, unpublish and publish revalidate both locales, and a content edit revalidates only its own locale.
  • On the old code, 3 of the 4 tests fail. On the new code, all 4 pass.
  • check-types passes and lint reports 0 errors.
  • api.int.spec.ts was not run here: it needs PAYLOAD_SECRET and a database.

…npublished or deleted

`_status` is not localized, but the page and post revalidation hooks only invalidated the locale from the
request's ?locale= (default en). Deleting or unpublishing a document left its other locales served from the
data cache, so /es/<slug> kept returning 200 after the page was deleted.

Status changes and deletes now invalidate all locales; content edits of a published document still
invalidate only the edited locale. revalidatePageCache takes a list of locales.

Scopes: apps/cms Page and Posts revalidation hooks, Header/Footer/GlobalBlock callers, lib/config/i18n, lib/utils/revalidatePageCache, tests/int.
@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ideal-cms Ready Ready Preview Oct 28, 2026 3:02pm UTC

Request Review

@dogfrogfog
dogfrogfog merged commit b70e4cd into main Oct 28, 2026
2 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.18.1 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.4.0 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

This branch was successfully deployed

1 active deployment
Preview — 8241871b Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant