Skip to content

Queue static cache purge requests - #202

Open
timkelty wants to merge 1 commit into
3.xfrom
t3code/cache-purge-producer-handoff
Open

Queue static cache purge requests#202
timkelty wants to merge 1 commit into
3.xfrom
t3code/cache-purge-producer-handoff

Conversation

@timkelty

Copy link
Copy Markdown
Contributor

Summary

  • Queue web-request static cache purge requests for asynchronous gateway processing.
  • Preserve immediate execution for console purges and header fallback when queue dispatch fails.
  • Add coverage for queued jobs, fetch URLs, retries, and fallback behavior.

Testing

  • Added and updated unit tests in tests/unit/StaticCacheTest.php.
  • Verified queued gateway purge payloads and 40-second timeout handling.
  • Verified console purges execute immediately.

- Run console purges immediately
- Fall back to purge headers when queue dispatch fails
Copilot AI lite review requested due to automatic review settings August 28, 2026 21:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-28T21:38:48.365034Z 5c10856 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/StaticCache.php
RequestOptions::TIMEOUT => 40,
]);
if ($isWebResponse) {
Craft::$app->getQueue()->push($job);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 PurgeStaticCacheJob for 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants