Queue static cache purge requests - #202
Conversation
- Run console purges immediately - Fall back to purge headers when queue dispatch fails
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: 5c10856488
ℹ️ 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".
| RequestOptions::TIMEOUT => 40, | ||
| ]); | ||
| if ($isWebResponse) { | ||
| Craft::$app->getQueue()->push($job); |
There was a problem hiding this comment.
Handle a null queue push as dispatch failure
When the configured queue declines the push by returning null rather than throwing—for example, when a before-push handler cancels it—this path treats dispatch as successful even though the purge header was already removed. The saved-element purge is then neither queued nor sent through the response header, leaving the cached page stale; check the returned job ID and apply the same header fallback when it is null.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR moves static cache purge requests that originate from web requests into a Craft queue job so gateway purges can be processed asynchronously, while preserving synchronous behavior for console contexts and keeping the response-header fallback when queue dispatch fails.
Changes:
- Replace inline gateway purge HTTP calls with a queued
PurgeStaticCacheJobfor web-request purges (and execute immediately for console/non-web responses). - Add/adjust unit tests to validate queued job payloads, execution timing, timeout behavior, and header fallback on queue push failure.
- Update README static cache documentation to reflect the new queued purge behavior and fallback semantics.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tests/unit/StaticCacheTest.php |
Adds a capturing queue and expands tests to assert queuing, fallback behavior, and immediate console execution. |
src/StaticCache.php |
Queues purge jobs for web responses (with fetch URLs) and executes the job immediately for non-web responses; retains header fallback on dispatch failure. |
src/queue/PurgeStaticCacheJob.php |
Introduces a new queue job responsible for making the gateway cache/purge request with tags and optional fetch URLs. |
README.md |
Updates static cache documentation to describe queuing behavior and response-header fallback when dispatch fails. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Summary
Testing
tests/unit/StaticCacheTest.php.