Skip to content

design: invalidate cached pages from the admin, the CLI and the REST API - #4587

Merged
swissky merged 4 commits into
emdash-cms:mainfrom
swissky:design/manual-cache-invalidation
Nov 27, 2026
Merged

swissky merged 4 commits into
emdash-cms:mainfrom
swissky:design/manual-cache-invalidation

Conversation

@swissky

@swissky swissky commented Nov 2, 2026

Copy link
Copy Markdown
Member

Design proposal

Proposal: proposals/manual-cache-invalidation.md

Content written outside EmDash (for example wrangler d1 execute --remote) leaves the route cache and object cache stale, and EmDash has no way to refresh them. On Cloudflare a zone purge doesn't reach Workers Cache, so site owners are left with a redeploy or a hand-written purge endpoint.

This plan adds one admin-only route, POST /_emdash/api/settings/cache/invalidate, plus an emdash cache invalidate command and a Cache settings page with "Refresh all pages" and "Refresh a path". Targets are entries, paths, tags, or all EmDash content. Route-cache invalidation goes only through Astro's cache.invalidate(), so core gets no Cloudflare-specific code. The route reuses the existing settings:manage permission and token scope, so the auth package doesn't change.

Proposal type

  • Feature plan
  • RFC
  • Amendment, supersession, or withdrawal

Related work

Discussion: #2021

Readiness

  • The proposal identifies its author and, for an RFC, its champion and Maintainer sponsor
  • The proposal describes observable behavior, compatibility, failure handling, and verification in proportion to its risk
  • Conflicting accepted or pending proposals are reconciled in this pull request
  • This pull request contains no implementation code
  • The proposal status is accepted (check only when ready to merge)

AI assistance

  • This proposal used AI assistance — model/tool: Claude Opus 5.5

@changeset-bot

changeset-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c58f135

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@wUEZRs

wUEZRs commented Nov 3, 2026

Copy link
Copy Markdown

On the open question "Should Editors be able to refresh a single path?": yes from us, and ideally "Refresh all pages" too.

Our setup: we're moving from WordPress with Cloudflare APO to EmDash. Our content editors work as Editors. On WordPress they cleared stale pages themselves with the Cloudflare plugin's purge button, while IT typically used the Cloudflare account. On EmDash, after a fix that doesn't purge on its own (a byline or media change), our current workaround is an IT redeploy. In our testing, zone "Purge Everything" did not clear Workers Caching.

Suggestion: a separate permission (for example cache:invalidate) granted to Editors by default, covering "Refresh a path" and "Refresh all pages", so routine fixes don't need an Admin and settings:manage stays Admin-only. Invalidation should leave publication and access controls unchanged; broader refresh permissions should account for load, availability and purge-API limits. We tag every route with all for this reason, so the "Also refresh pages tagged all" checkbox would cover us; please keep it.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Approval status

The current revision meets the approval requirements.

  • ✅ 1 human Maintainer approval from someone other than the author (normal change); found 1: @ascorbic.
  • ✅ No outstanding change requests.

This comment updates as reviews arrive. See MAINTAINING.md and the proposal process for the rules.

@swissky

swissky commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

Thanks a lot @wUEZRs for describing your setup, that's exactly the kind of use case this plan needs.

I've kept this plan Admin-only for now, because #2021 asked for that and an Editor permission means a new permission and token scope in the auth package, plus some limit on how often the expensive "refresh all" request can run. I added your cache:invalidate idea to the open questions as a follow-up proposal, so it doesn't get lost.

The "Also refresh pages tagged all" checkbox stays. In the meantime, an Admin-created API token with settings:manage would let your IT team run emdash cache invalidate --path ... from a script instead of redeploying.

## Open questions

- Is 10 purge requests per call the right ceiling, or should the limit follow the provider?
- Should Editors be able to refresh a single path or all pages? This plan limits every action to Admins, as #2021 asks. A site moving from WordPress, where editors purged pages themselves, asked for a separate `cache:invalidate` permission granted to Editors. That needs a new permission and token scope in the auth package, and a limit on how often Editors can trigger the expensive "all" request, so it is left to a follow-up proposal.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep this to admins for now I think

@emdashbot emdashbot Bot removed the review/needs-review No maintainer or bot review yet label Nov 27, 2026
@emdashbot emdashbot Bot added review/needs-review No maintainer or bot review yet and removed review/needs-review No maintainer or bot review yet labels Nov 27, 2026
@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Nov 27, 2026
@swissky
swissky enabled auto-merge (squash) November 27, 2026 16:26
@swissky
swissky merged commit 29bcb31 into emdash-cms:main Nov 27, 2026
32 checks passed
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.

3 participants