Skip to content

Revalidate purged static cache URLs#188

Merged
timkelty merged 15 commits into
3.xfrom
timkelty/static-cache-revalidation
Jul 19, 2026
Merged

Revalidate purged static cache URLs#188
timkelty merged 15 commits into
3.xfrom
timkelty/static-cache-revalidation

Conversation

@timkelty

@timkelty timkelty commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a cancelable before-purge event with mutable normalized tags and optional element context
  • send deduplicated saved-element URLs as the optional fetchUrls purge payload so the gateway can asynchronously repopulate purged pages
  • keep deletions, URL-less saves, and canceled purges from enqueueing fetches, while preserving header fallback when the gateway request fails
  • bound gateway purge requests to three seconds so element-save responses cannot stall indefinitely
  • use native invalidation-event element context when available while retaining the legacy draft/revision tag fallback for older Craft releases
  • make purgeOrigin() canonical while retaining purgeGateway() as a deprecated alias
  • document Yii DI event configuration and the fetchUrls behavior

Testing

  • composer test (78 tests, 226 assertions, 1 existing Craft 4 skip)
  • composer phpstan
  • composer cs:check
  • composer validate --no-check-publish
  • git diff --check

Copilot AI review requested due to automatic review settings July 17, 2026 00:58

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

Adds a cancelable pre-purge event and extends static cache purging to optionally include public element URLs (fetchUrls) so the gateway can re-fetch and repopulate the static cache after purges.

Changes:

  • Introduces StaticCache::EVENT_BEFORE_PURGE with a new PurgeEvent (cancelable + mutable tags + optional element context).
  • Collects/deduplicates eligible public element URLs and includes them as fetchUrls in gateway tag purge requests (and avoids response-header purges when URL fetch is needed).
  • Updates unit tests and README documentation to cover event configuration and fetchUrls behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unit/StaticCacheTest.php Adds coverage for the new before-purge event and fetchUrls gateway payload behavior.
src/StaticCache.php Implements before-purge event, URL collection/deduping, and gateway payload support for fetchUrls.
src/Module.php Refactors config caching field name ($_config$config).
src/events/PurgeEvent.php Adds new cancelable purge event type carrying tags and element context.
README.md Documents configuring the new purge event via Yii DI and explains fetchUrls behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/unit/StaticCacheTest.php
@timkelty
timkelty marked this pull request as ready for review July 17, 2026 01:05

@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: 1d4e99c3f7

ℹ️ 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 Outdated
@timkelty
timkelty marked this pull request as draft July 17, 2026 11:18
Copilot AI review requested due to automatic review settings July 17, 2026 11:20

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread src/StaticCache.php
@timkelty
timkelty marked this pull request as ready for review July 17, 2026 11:26

@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: 0f543ef224

ℹ️ 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 Outdated
@timkelty
timkelty marked this pull request as draft July 17, 2026 11:33
Copilot AI review requested due to automatic review settings July 17, 2026 11:34

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@timkelty
timkelty marked this pull request as ready for review July 17, 2026 11:39
@timkelty
timkelty marked this pull request as draft July 17, 2026 12:29
Copilot AI review requested due to automatic review settings July 17, 2026 12:33

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread src/events/PurgeEvent.php
Copilot AI review requested due to automatic review settings July 17, 2026 12:37

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread src/StaticCache.php Outdated

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread src/StaticCache.php
@timkelty
timkelty marked this pull request as ready for review July 19, 2026 03:25

@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: 1cfd4f8186

ℹ️ 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
@timkelty
timkelty marked this pull request as draft July 19, 2026 03:31
Copilot AI review requested due to automatic review settings July 19, 2026 03:34

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@timkelty
timkelty marked this pull request as ready for review July 19, 2026 03:39

@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: 24e3bfdef8

ℹ️ 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
@timkelty
timkelty marked this pull request as draft July 19, 2026 10:39
Copilot AI review requested due to automatic review settings July 19, 2026 10:39

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

Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.

@timkelty
timkelty marked this pull request as ready for review July 19, 2026 10:43
@timkelty
timkelty marked this pull request as draft July 19, 2026 13:30
Copilot AI review requested due to automatic review settings July 19, 2026 13:30

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread tests/unit/StaticCacheTest.php Outdated
Comment thread src/StaticCache.php
Copilot AI review requested due to automatic review settings July 19, 2026 13:35

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@timkelty
timkelty marked this pull request as ready for review July 19, 2026 13:39
@timkelty
timkelty marked this pull request as draft July 19, 2026 15:06
@timkelty
timkelty marked this pull request as ready for review July 19, 2026 15:07
@timkelty
timkelty merged commit 2349b20 into 3.x Jul 19, 2026
10 checks passed
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