fix(core): invalidate edge cache on settings/menu writes (#2042)#2131
Open
swissky wants to merge 2 commits into
Open
fix(core): invalidate edge cache on settings/menu writes (#2042)#2131swissky wants to merge 2 commits into
swissky wants to merge 2 commits into
Conversation
…2042) Editing site settings or a menu never evicted rendered HTML from the Cloudflare Workers route cache — pages went stale until maxAge lapsed. Settings and menu write paths now purge reserved route-cache tags (emdash:settings, emdash:menus), and the pages that render them are tagged so the purges reach them: EmDashHead tags emdash:settings, menu widgets tag emdash:menus. Sites calling getMenu() directly can opt in with Astro.cache.set({ tags: [EDGE_TAG_MENUS] }). Docs explain the publish-vs-eviction contract.
🦋 Changeset detectedLatest commit: fa1d6a6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
ascorbic
reviewed
Jul 20, 2026
ascorbic
left a comment
Collaborator
There was a problem hiding this comment.
I think middleware is probably the best place to set these
| // This page renders site settings, so it must be evicted when they change. | ||
| // Tag it with the reserved settings tag so the settings write path's purge | ||
| // reaches it (#2042). Merges with any tags the route already set. | ||
| Astro.cache.set({ tags: [EDGE_TAG_SETTINGS] }); |
Collaborator
There was a problem hiding this comment.
This is risky to put inside a component, because depending on how it's used, there's a chance the headers will have already been sent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Editing site settings or a menu never evicted rendered HTML from the Cloudflare Workers route cache. Pages went stale until their
maxAgelapsed, even though the in-memory object cache was invalidated.This PR closes the gap:
emdash:settingsandemdash:menusplus aninvalidateEdgeTag()helper (packages/core/src/astro/edge-cache-tags.ts).POSTroute and every state-changing menu route (create / update / delete / reorder / translate / item update / item delete) now purge their reserved tag on success — no-op when no cache provider is configured, same contract as the content write paths.<EmDashHead>addsemdash:settings, and menu widgets (WidgetRenderer) addemdash:menus.getMenu()directly can opt a page into the same invalidation withAstro.cache.set({ tags: [EDGE_TAG_MENUS] })(both tags are now exported fromemdash).Closes #2042
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.AI-generated code disclosure
Screenshots / test output