Skip to content

Prevent proxy cache key fan-out - #4

Merged
TorstenDittmann merged 2 commits into
mainfrom
agent/cloudflare-cache-tag-purge
Aug 13, 2026
Merged

Prevent proxy cache key fan-out#4
TorstenDittmann merged 2 commits into
mainfrom
agent/cloudflare-cache-tag-purge

Conversation

@TorstenDittmann

Copy link
Copy Markdown
Contributor

What changed

  • Reject non-empty purgeKeys() calls made through the cache Proxy.
  • Preserve domain and path routing behavior, including intentional custom-domain fan-out.
  • Keep empty key purges as a no-op.
  • Document that consumers must resolve the service- or zone-scoped adapter before constructing Cache.

Why

Cache keys and tags are scoped to a specific Fastly service or Cloudflare zone. The proxy has only domain-routing configuration and no application Rule context, so broadcasting a key purge to every configured adapter can invalidate unrelated services or zones.

After this change, applications select the appropriate adapter using their own routing context and pass that adapter directly to Cache.

Impact

Callers using Proxy::purgeKeys() with non-empty keys now receive an UnsupportedOperation exception instead of an implicit fan-out. Direct Fastly and Cloudflare adapter key purges are unchanged.

Validation

  • PHPUnit: 26 tests, 50 assertions
  • Pint lint
  • PHPStan analysis

@TorstenDittmann
TorstenDittmann marked this pull request as draft August 12, 2026 15:10
@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown

Greptile Summary

The PR prevents cache-key purge fan-out across unrelated Fastly services or Cloudflare zones by rejecting non-empty key purges through the domain-routing proxy.

  • Keeps domain and path routing behavior unchanged.
  • Preserves empty key purges as no-ops.
  • Documents that consumers must resolve the service- or zone-scoped adapter before constructing Cache.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/Cdn/Cache/Adapter/Proxy.php Replaces cross-adapter key-purge fan-out with an explicit exception while retaining the empty-input no-op.
tests/Cdn/Cache/Adapter/ProxyTest.php Updates routing expectations and verifies both rejection of non-empty key purges and no-op handling for empty keys.
README.md Clarifies the proxy’s routing scope and documents adapter resolution for service- or zone-scoped key purges.

Fix All in Greploop

Reviews (2): Last reviewed commit: "Merge branch 'main' into agent/cloudflar..." | Re-trigger Greptile

@TorstenDittmann
TorstenDittmann marked this pull request as ready for review August 13, 2026 14:17
@TorstenDittmann
TorstenDittmann merged commit 6f372aa into main Aug 13, 2026
3 checks passed
@TorstenDittmann
TorstenDittmann deleted the agent/cloudflare-cache-tag-purge branch August 13, 2026 14:17
Meldiron added a commit that referenced this pull request Aug 13, 2026
Cache\Adapter\Proxy hard-codes one deployment's routing into the library:
an app domain, a set of network domains, and a list of adapters for
everything else. Any consumer whose split is not exactly that cannot use
it, and a consumer whose split is that has encoded its topology in a
dependency it does not control.

#4 has since established that it cannot route key purges at all, since keys
are scoped to a service or zone, and told consumers to select the adapter
themselves before constructing Cache. That is the same conclusion for every
operation, not only keys.

Nothing uses it. Its only references were its own test and the README.

Certificates\Provider\Proxy is untouched; this removes the cache adapter
only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Meldiron Meldiron mentioned this pull request Aug 13, 2026
4 tasks
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.

1 participant