Repository navigation
Fix purging of pages that embed a cached include via SSI - #918
Merged
Merged
Conversation
`RefreshCacheService::getSsiIncludeSiteUris()` derived the include index from
an `index` query string param. Since the cached include URI refactor in 5.12.0
the index lives in the path (`_cached_include_{index}?p=_cached_include_{index}`),
so the lookup never matched and pages embedding a refreshed include were not
purged from the reverse proxy.
The index is now read from the path prefix, falling back to the legacy query
string param, and the DB query is skipped when no include URIs are given.
karensg
force-pushed
the
fix-ssi-include-purge
branch
from
September 15, 2026 10:24
ec8c69d to
6f1c490
Compare
Collaborator
|
Thanks for the bug report and PR! Merged and released in 5.13.2. |
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.
Bug
With
ssiEnabledand a reverse proxy purger (Cloudflare in our case), refreshing a cached include does not purge the pages that embed it. The include itself is refreshed and purged, but the reverse proxy keeps serving the previously assembled page until its TTL expires.Cause:
RefreshCacheService::getSsiIncludeSiteUris()derives the include index from anindexquery string param:Since the cached include URI refactor in 5.12.0 (29177e4), cached include site URIs are stored as
_cached_include_{index}?{cachedIncludePathParam}=_cached_include_{index}, so$indexis alwaysnull, theSsiIncludeCacheRecordlookup matches nothing and no embedding pages are added to$purgeableSiteUrisinrefreshSiteUris().Reproduction
Blitz 5.12.15 (and current
develop), Craft 5.11.1, SSI enabled, Cloudflare purger.craft.blitz.includeCached('counter.twig')whose template runs a tracked element query.Blitz::$plugin->refreshCache->getSsiIncludeSiteUris([$includeSiteUri]), with the include's stored site URI, returns[]althoughblitz_ssiincludecacheshas a row linking the include to the page.age: 67816, a signature counter 300+ behind the origin).Fix
_cached_include_path prefix, the same wayCacheRequestServicedetects cached includes, with a fallback to the legacyindexquery param for URIs created by versions before 5.12.0.IN ().Verified against our production records: the patched lookup returns the embedding page for both
_cached_include_92856835?p=_cached_include_92856835and the legacy_includes?action=blitz/include/cached&index=92856835.Tests
Three Pest tests added to
RefreshCacheTest: current URI format, legacy URI format, and a non-include URI. I could not run the Pest suite locally (it needs a Craft test install), so please run it on your side.ecs checkpasses on the changed files;phpstanreports only the pre-existing implicit-nullable notice onaddElementQuery().