Skip to content

SouinPurger sends PURGE but Caddy cache-handler only supports DELETE; docs show invalid Laravel purger config #8258

@PicassoHouessou

Description

@PicassoHouessou

API Platform version(s) affected: v4.3.10 (api-platform/laravel + api-platform/http-cache)

Description

SouinPurger (and its parent SurrogateKeysPurger) hardcodes Request::METHOD_PURGE when calling the invalidation endpoint. However, the Caddy cache-handler management API (documented for use at http://caddy:2019/souin-api/souin) only supports DELETE with a Surrogate-Key header — it does not handle PURGE. Sending PURGE to that endpoint returns an empty response, causing API Platform to throw a 500 on every mutation even though the write itself succeeded.

Additionally, the performance documentation shows this for Laravel:

'purger' => 'api_platform.http_cache.purger.souin',

This is a Symfony DI service alias. In Laravel, ApiPlatformEventProvider resolves the purger via class_exists() then $app->make() — a service ID string will throw InvalidArgumentException ("class not found") or fail DI resolution. The correct value for Laravel is the FQCN (\ApiPlatform\HttpCache\SouinPurger::class), but even that triggers the PURGE issue above.

How to reproduce

  1. Set up FrankenPHP + Caddy cache-handler with api { basepath /souin-api; souin } on port 2019
  2. Configure Laravel as per the docs with SouinPurger
  3. Send any POST/PATCH/DELETE — response is 500: "Empty reply from server for http://localhost:2019/souin-api/souin"
  4. Confirm the mismatch:
    • DELETE /souin-api/souin + Surrogate-Key: test200 OK
    • PURGE /souin-api/souinempty reply

Possible Solution

  1. Make SurrogateKeysPurger::getChunkedIris() protected instead of private so subclasses can override purge() without duplicating the chunking logic.
  2. Add a constructor parameter for the HTTP method so users can choose without writing a full custom purger.
  3. Fix the Laravel docs example to use the FQCN instead of the Symfony service alias, or update ApiPlatformEventProvider to support service ID resolution for the purger config key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions