Docs

This page isn't translated yet

Auto-purge

What gets purged on publish and purging from your own hooks.

On this page

Every seam that already revalidates Next.js also purges the matching Cloudflare edge cache, so an edit invalidates both caches together:

What gets purgedLink to this section

TriggerPurges
Page publish/update/deleteThe page's paths (old + new, including descendants) and the homepage when affected
Component used across pagesEvery page that renders it
Form used across pagesEvery page that renders it
Redirect create/update/deleteThe redirect's from path
Post publish/unpublish/update/delete (Posts module)Every path the post hooks revalidate, in every affected locale (see below)
Category or tag edit/delete, author byline changeEvery path the post hooks revalidate, in every affected locale (see below)
Upload file or alt change on an image posts useThe posts that render it, their listings and the homepage
Upload's alt text changesThe whole zone (whole-site purge — other upload changes don't trigger a purge)
Header, Footer, or SEO global saveThe whole zone (purge_everything)
A general-settings change that revalidates everythingThe whole zone (purge_everything)
General Settings → Troubleshoot tab's "Revalidate site" actionThe whole zone (purge_everything)
The /systhema/revalidate route (paths: '*' or a list)The whole zone, or the matching URLs

The Posts module purges the same paths it revalidates: the post's permalink (and its old permalink when it moved or was unpublished), the homepage, every archive-template Page and every Page embedding a posts block (the category, tag, author and archive listings), and the sibling posts whose Related rail shows it. A category whose slug changes under a {category} permalink also purges the affected posts' old URLs. A body-only edit of a published post purges only that post. Each save issues one purge with every affected locale's public URL.

How auto-purge behavesLink to this section

Auto-purge is a guarded no-op: it does nothing unless Cloudflare is enabled and the effective auto-purge toggle is on, and it never throws — a purge failure is logged and swallowed so it can never break a Payload hook or a page publish.

The autoPurge toggle precedence: the persisted cloudflare global's autoPurge field, when the global exists and is readable, always overrides the cloudflare plugin option's autoPurge default. This lets a project change the behavior from the admin UI without redeploying. The effective value is cached in memory for a few seconds per Payload instance so a burst of revalidations during a bulk edit doesn't issue a database read per path.

The siteUrl requirement: purging specific paths needs an absolute URL, built from siteUrl (the plugin option) or, when that's omitted, the Payload config's serverURL. If neither resolves, path-level auto-purge silently skips the Cloudflare leg (logging a warning) while the Next.js revalidation still runs — pages are never left un-revalidated because Cloudflare couldn't be reached.

Cache rules restricted by method must include PURGE. Cloudflare evaluates cache rules with the request method PURGE when it purges a single URL. A rule that caches HTML only for GET/HEAD makes every purge report success while evicting nothing, so add PURGE to the rule's method list (or drop the method condition).

Purging from your own hooksLink to this section

Collections you add yourself are not covered by auto-purge. Call autoPurgePaths from @systhemaui/payload next to your own revalidatePath calls. It takes the Payload instance and public paths (or absolute URLs on a site you publish through), builds absolute URLs from siteUrl, groups them by zone, and follows the same rules as auto-purge: a no-op unless Cloudflare and auto-purge are on, and it never throws. Import it only from server code; the root entry is not client-safe.

import type { CollectionAfterChangeHook } from 'payload'
import { autoPurgePaths } from '@systhemaui/payload'

export const revalidateEvent: CollectionAfterChangeHook = async ({ doc, req, context }) => {
  if (context?.disableRevalidate) return doc

  const { revalidatePath } = await import('next/cache')
  const paths = [`/events/${doc.slug}`, '/events']
  for (const path of paths) revalidatePath(path)
  void autoPurgePaths(req.payload, paths)

  return doc
}

On a multilingual site, pass each locale's public path (for example /hu/esemenyek/..., or the full URL on a locale domain), not the internal route you revalidate.