Skip to content

chore(templates): revalidate archive block data#17405

Open
rasitakyol wants to merge 1 commit into
payloadcms:mainfrom
rasitakyol:agent/fix-website-archive-revalidation
Open

chore(templates): revalidate archive block data#17405
rasitakyol wants to merge 1 commit into
payloadcms:mainfrom
rasitakyol:agent/fix-website-archive-revalidation

Conversation

@rasitakyol

Copy link
Copy Markdown
Contributor

What?

Caches collection-populated Website Template Archive Block queries and revalidates them when posts are published, unpublished, or deleted.

Why?

Archive Blocks can remain stale after post changes because their Local API query is part of a statically cached route and the template does not know every page that contains the block. A shared data tag invalidates every Archive Block consumer without tracking page paths.

How?

  • Moves the collection-mode post query into one unstable_cache function tagged with posts-archive, consistent with the template's existing caching model.
  • Passes the limit and normalized category IDs as function arguments so each query variant gets its own cache key.
  • Revalidates the shared tag from the existing post publish, unpublish, and delete hooks.
  • Keeps overrideAccess: false on the cached query so draft or unpublished posts cannot enter the shared cache.
  • Adds focused coverage for cache registration, access enforcement, query normalization, and hook invalidation.

This overlaps with #15944, which adds overrideAccess: false to the current inline query. This PR relocates that query and preserves the same access-control requirement; it is not intended to supersede #15944 and should be rebased if that PR merges first.

Testing

  • pnpm exec vitest run --config ./vitest.config.mts tests/int/archiveBlockCache.int.spec.ts (7 passed)
  • Focused Prettier and diff checks
  • Full template build attempted: application compilation completed, then monorepo type checking stopped on the existing packages/db-mongodb/src/find.ts:151 type error. No changed-file type errors were reported.

Related discussion: #15722

@rasitakyol
rasitakyol marked this pull request as ready for review July 19, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant