Repository navigation
Conversation
Send automatic cache batches through the coordinated gateway invalidation endpoint while preserving explicit purge behavior and response-header fallback. The gateway invalidate route must be deployed before this client change. Amp-Thread-ID: https://ampcode.com/threads/T-01a0fcfa-f02f-7279-bde1-e8d7ce2ef59b Co-authored-by: Amp <amp@ampcode.com>
Add invalidate variants for the existing all, CDN, origin, prefix, and tag purge commands while keeping the explicit purge commands available. Amp-Thread-ID: https://ampcode.com/threads/T-01a0fcfa-f02f-7279-bde1-e8d7ce2ef59b Co-authored-by: Amp <amp@ampcode.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca57f99a83
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| { | ||
| $response = Craft::$app->getResponse(); | ||
| $isWebResponse = $response instanceof \craft\web\Response; | ||
| $tags = $this->preparePurgeTags($tags, $isWebResponse); |
There was a problem hiding this comment.
Preserve hard-purge headers during invalidation
When a web request already has a Cache-Purge-Tag header (for example, after calling purgeTags()) and also queues an automatic element or asset invalidation, this call tells preparePurgeTags() to merge that header into the invalidation batch and remove it from the response. On a successful cache/invalidate request, the explicit hard purge is therefore silently downgraded to an invalidation and never reaches the gateway as a purge header. The invalidation path should process only its supplied tags while preserving any existing hard-purge header.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Existing hard-purge headers can be downgraded to invalidations, and prefix invalidation lacks a request timeout.
Review effort: Balanced
Findings: 2
Open (3)
What changed in this PR
Adds native gateway cache invalidation while retaining explicit hard-purge operations and fallback headers.
Changes:
- Routes automatic tag invalidation through
cache/invalidate. - Adds tag/prefix invalidation APIs and CLI commands.
- Updates tests and documentation for tag-only invalidation.
| File | Description |
|---|---|
src/StaticCache.php |
Implements native tag and prefix invalidation. |
src/cli/controllers/StaticCacheController.php |
Adds invalidate-* commands. |
tests/unit/StaticCacheTest.php |
Tests invalidation payloads and fallback behavior. |
tests/unit/StaticCacheControllerTest.php |
Covers purge and invalidation commands. |
README.md |
Documents invalidation event behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| { | ||
| $response = Craft::$app->getResponse(); | ||
| $isWebResponse = $response instanceof \craft\web\Response; | ||
| $tags = $this->preparePurgeTags($tags, $isWebResponse); |
| Helper::createGatewayApiClient()->request('POST', 'cache/invalidate', [ | ||
| RequestOptions::JSON => [ | ||
| 'prefixes' => $urlPrefixes->values()->all(), | ||
| ], | ||
| ]); |
| $module = Module::getInstance(); | ||
| $environmentId = $this->environmentId(); |


Description
Use the Cloudflare invalidation endpoint for automatic static-cache tag invalidation instead of coupling invalidation to URL fetching. This removes
fetchUrlscollection and payload handling while preservingEVENT_BEFORE_PURGEand the existingCache-Purge-Tagfallback when a web request fails.Adds explicit
invalidate-*console commands alongside the existingpurge-*commands so hard purges remain available. The coordinated gateway invalidation endpoint must be deployed before this change.Implementation thread: https://ampcode.com/threads/T-01a0fcfa-f02f-7279-bde1-e8d7ce2ef59b