Skip to content

fix(httpcache): allow custom http method on SouinPurger and SurrogateKeysPurger#8259

Open
soyuka wants to merge 1 commit into
api-platform:4.3from
soyuka:fix/httpcache-souin-purger-delete-8258
Open

fix(httpcache): allow custom http method on SouinPurger and SurrogateKeysPurger#8259
soyuka wants to merge 1 commit into
api-platform:4.3from
soyuka:fix/httpcache-souin-purger-delete-8258

Conversation

@soyuka
Copy link
Copy Markdown
Member

@soyuka soyuka commented Jun 8, 2026

Summary

SouinPurger (and its parent SurrogateKeysPurger) hardcodes PURGE when calling the invalidation endpoint. Backends like the Caddy cache-handler souin-api endpoint only accept DELETE with a Surrogate-Key header, so every mutation currently fails with a 500 even though the write succeeded. This PR adds an optional $method constructor parameter (default Request::METHOD_PURGE, fully BC) so users can configure DELETE without writing a custom purger.

Reproduction

Configure SouinPurger against a Caddy cache-handler api { basepath /souin-api; souin } endpoint; any POST/PATCH/DELETE returns 500 with "Empty reply from server" because Caddy's endpoint only handles DELETE, not PURGE.

Test plan

  • Added failing test (SouinPurgerTest::testPurgeWithCustomHttpMethod) covering the new constructor argument.
  • Test passes after the fix.
  • All existing HttpCache tests still pass locally (36/36).

Fixes #8258

…KeysPurger

The hardcoded PURGE verb prevents using purgers with backends that only
accept DELETE for cache invalidation (e.g. the Caddy cache-handler
souin-api endpoint, which documents DELETE + Surrogate-Key only).

Adds a new optional $method constructor parameter on
SurrogateKeysPurger and SouinPurger (default Request::METHOD_PURGE, so
existing setups are unchanged). Users on Caddy/Souin can now configure
the purger with Request::METHOD_DELETE instead of subclassing.

Fixes api-platform#8258
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