Adds an endpoint and a dashboard button to the Payload admin that calls revalidateTag for the tags you supply. Access is limited by a canRefresh function, with a confirmation step, CSRF-style origin checks, and a lock with cooldown. Defaults to stale-while-revalidate and can warm pages afterward. Requires Payload 3.80+ and Next.js 16+.
Cache refresh for Payload: an admin button that refreshes the host's Next.js cache tags for the people the host allows, with a confirmation step, stale-while-revalidate by default, a targeted or full refresh, optional page warming and an audit hook.
Installation
npm i @extantape/payload-plugin-cache-refresh0
Stars
0
Forks
0
Open Issues
6 days ago
Last Updated
385
Weekly Downloads
v0.2.0
npm Version
39.5 KB
Unpacked Size
0
Dependencies
00 since Nov 15
| Date | Stars |
|---|---|
| Dec 5, 2026 | 0 |
| Dec 4, 2026 | 0 |
| Dec 3, 2026 | 0 |
| Dec 2, 2026 | 0 |
| Dec 1, 2026 | 0 |
| Nov 30, 2026 | 0 |
| Nov 29, 2026 | 0 |
| Nov 28, 2026 | 0 |
| Nov 27, 2026 | 0 |
| Nov 26, 2026 | 0 |
| Nov 25, 2026 | 0 |
| Nov 24, 2026 | 0 |
| Nov 23, 2026 | 0 |
| Nov 22, 2026 | 0 |
| Nov 21, 2026 | 0 |
| Nov 20, 2026 | 0 |
| Nov 19, 2026 | 0 |
| Nov 18, 2026 | 0 |
| Nov 17, 2026 | 0 |
| Nov 16, 2026 | 0 |
| Nov 15, 2026 | 0 |
354+166 since Nov 23
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 354 |
| Dec 4, 2026 | 335 |
| Dec 3, 2026 | 315 |
| Dec 2, 2026 | 294 |
| Dec 1, 2026 | 60 |
| Nov 30, 2026 | 244 |
| Nov 29, 2026 | 241 |
| Nov 28, 2026 | 239 |
| Nov 27, 2026 | 237 |
| Nov 26, 2026 | 221 |
| Nov 25, 2026 | 214 |
| Nov 24, 2026 | 188 |
| Nov 23, 2026 | 188 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1464319394-root)<a href="https://payloaddirectory.dev/plugins/1464319394-root"><img src="https://payloaddirectory.dev/badge/1464319394-root.svg" alt="Payload Directory"></a>README
Cache refresh for Payload: a dashboard button that refreshes your Next.js site's cache tags, for the people you choose, after a confirmation.
Status: early. Version 0.2.0, a security release, is on npm; see the changelog. The plugin is covered by 110 unit tests with next/cache.js mocked: who may refresh, the same-site check and the allowed origins, the lock and cooldown, the confirmation step, a failing tag list, a tag that fails to refresh, a logger or hook that throws something other than an error, the audit hook, stale or expire, changed tags or everything, warming, and the words the button shows for each reply. It has not been run against a real Next.js app yet, the button has not been rendered in a browser, and the screen reader behavior is untested.
canRefresh function allows.confirm: true, so the confirmation holds for API calls too.revalidateTag for each tag you give it. It knows nothing about your tag names, routes or roles.changedTags, the button refreshes only those by default. The admin can choose Everything.onRefresh with who, when and how many, for your audit trail.Signed-out requests get 401. A signed-in user your rule refuses gets 403, and a rule that throws counts as a no. Payload's own auth applies to the endpoint.
Payload's CSRF check does not cover this endpoint: a form on another site can post text/plain with the admin's cookie and no preflight. So the plugin checks the request itself. The refresh needs Content-Type: application/json (415 otherwise), and the browser must show it came from this site: Sec-Fetch-Site must be same-origin if sent, and Origin must match the allowed origins if sent. A request with neither header gets 403. An Origin of null is always refused.
When the browser sends Origin, it is checked against the allowed origins. Those are allowedOrigins when you set it, and then only that list, never the request's own origin. It must hold at least one entry, and every entry must be an http or https address such as https://admin.example.org, or the plugin refuses to start with an error saying which entry to fix. Leave it unset to use Payload's serverURL, or the origin of the request URL when serverURL is empty (Payload's default) or isn't an http or https address. Set one of the two if a proxy changes the request URL.
A second press while a refresh runs, or within cooldownMs after one, gets 429.
If the tag list can't be read (a function throws, or a tag is empty or longer than 256 characters), nothing is refreshed.
If Next.js fails to refresh a tag, the plugin still tries the rest, so as much of the site as possible is fresh. The reply is then a 500 with refreshed: false, count (the tags that refreshed) and failed (the ones that didn't). Each failure is written to Payload's log. The reply never carries the error text. onRefresh gets only the tags that refreshed, with the failed count, so if you clear recorded tags there you clear only those. Nothing is warmed after a failure. The button says how many tags refreshed and how many didn't, and suggests trying again.
On its own: Cache Refresh needs only Payload and Next.js. It adds one endpoint and a dashboard button, and refreshes the tags your site records. It doesn't depend on any other plugin.
Needs: Payload ^3.80.0 and Next.js >=16.0.0 as peer dependencies, with React ^19.0.0 optional. No other EXTANT APE plugin is required.
Works with:
onRefresh can call Audit Trail's recordEvent, so each refresh is kept with who ran it and how many tags it refreshed. That's your own code, and neither plugin imports the other.Color Theory: no direct link. The dashboard button uses its own --cache-refresh-* variables, which fall back to Payload's --theme-* colors, so it follows Color Theory's admin colors when its applyToAdmin option is on. Its focus ring falls back to a fixed orange.
npm install @extantape/payload-plugin-cache-refresh
Needs Payload 3.80 or later and Next.js 16 or later, which has the two-argument revalidateTag.
import { cacheRefreshPlugin } from '@extantape/payload-plugin-cache-refresh'
export default buildConfig({
plugins: [
cacheRefreshPlugin({
canRefresh: (req) => req.user?.role === 'admin',
tags: ['pages', 'posts', 'menu'],
}),
],
})
Regenerate Payload's import map after adding it, so the button is found.
| Option | What it does |
|---|---|
canRefresh(req) | Required. Returns true for users who may refresh. |
tags | Required. A list, or an async function returning one. What Everything refreshes. |
changedTags({ req }) | Tags changed since the last refresh, for example ones your scripts recorded. When given, the button offers Only what changed (the default) and Everything. |
mode | 'stale' (default) or 'expire'. Stale calls revalidateTag(tag, profile). Expire calls revalidateTag(tag, { expire: 0 }), so the next visit waits for a fresh page. |
profile | The profile for stale mode. Default 'max'. |
warmPaths | A list of paths, or a function returning one, fetched after a refresh. A path starts with a single / and has no backslash. Anything else, such as //host or /\host, is refused and counted as failed. The URL is built on warmBaseUrl and its origin is checked again before the fetch. Redirects are not followed. |
warmBaseUrl | The site's address, such as https://example.org. Warming is off without it. |
warmTimeoutMs | Time for each warming fetch. Default 5000. |
warmDeadlineMs | Total time for all warming. Pages left when it passes are skipped and reported. Default 15000. |
cooldownMs | Time after a refresh before the next is accepted. Default 5000. |
allowedOrigins | Origins a refresh may come from, checked when the browser sends Origin. When set, only this list is used, and it needs at least one entry, each an http or https address, or the plugin refuses to start. Default Payload's serverURL, else the request's origin. |
onRefresh(report) | Gets who (id, collection, email), at, count, failed, scope, mode and tags. tags holds only the tags that refreshed, and failed counts the ones that didn't. If it throws, the refresh stays and the response says audited: false. It isn't called when zero tags were refreshed. |
endpointPath | Default /cache-refresh. |
adminButton | Default true. Set false and import CacheRefreshButton from @extantape/payload-plugin-cache-refresh/client to place it yourself. |
The plugin never clears your recorded changed tags. Do that in onRefresh, which receives the tags it refreshed.
The button's words can be replaced with the text prop (its partial, noneRefreshed and partialNotAudited entries cover a refresh that only partly went through), and its colors with --cache-refresh-ink, --cache-refresh-paper, --cache-refresh-line and --cache-refresh-focus.
MIT. Copyright (c) 2026 EXTANT APE.
payload revalidate
Transaction-aware cache revalidation hooks for Payload with a signed Next.js route handler
75218/wk3v3
payload feature flags
Feature toggles, percentage rollouts and A/B variants managed from the Payload admin panel
70191/wk4v3
sitemap
Chunked, lazily cached XML sitemaps with hook-driven invalidation and robots.txt helpers
62156/wk16v3
payload revalidate
Field-driven Next.js cache revalidation for Payload with id-keyed cached finders and a dependency map
59240/wk18v3
cached local api
Cache Payload Local API operations with Next.js unstable_cache and automatic tag-based revalidation
48112/wk335v3
payload plugin ga4 ecommerce
GA4 reporting dashboards and per-record analytics tabs inside the Payload admin panel
44115/wk10v3