Purging souin keys

1. Caddy version (caddy version):

v2.5.0 h1:eRHzZ4l3X6Ag3kUt8nj5IxATprhqKq/wToP7OHlXWA0=

2. How I run Caddy:

I am trying to use the cache module GitHub - caddyserver/cache-handler: Distributed HTTP caching module for Caddy to set & invalidate pages in the cache.

I can see the cache is working correctly on my responses:

GET /api/platform/test/cache

Age: 8
Cache-Control: max-age=200, public
Cache-Status: Souin; hit; ttl=192
Surrogate-Key: bla

Also on refresh I can see the request does not hit my upstream in the caddy logs and returns directly.
When I now visit the configured souin api I can see that the request is indeed listed:

[
"GET-localhost-/api/platform/test/cache",
"GET-localhost-/favicon.ico{-VARY-}Accept-Encoding:gzip, deflate, br",
"STALE_GET-localhost-/api/platform/test/cache",
"STALE_GET-localhost-/favicon.ico{-VARY-}Accept-Encoding:gzip, deflate, br"
]

My first question is: What happened to the surrogate-key I set? I was expecting to see a key:value list?

My second question is: How do I purge only one item on the displayed list? When I fire a PURGE request to the souin api with Surrogate-key header it purges the full cache instead of just the one item?

Anyone able to give me a pointer I think im stuck on a small thing.

"apps"  => [
                "cache" => [
                    'api'       => [
                        'basepath' => '/__cache',
                        'souin' => [
                            'basepath' => '/souin',
                            'enable'   => true,
                        ],
                    ],
                    "log_level" => "DEBUG",
                    'ttl'       => '3600s',
                ],
]

4. Error messages and/or full log output:

When sending a PURGE request with the specified Surrogate-Key: bla header it seems to DropPrefix for [ ] instead of just my key?

caddy_1                | badger 2022/05/15 05:52:53 INFO: DropPrefix called for []
caddy_1                | badger 2022/05/15 05:52:53 INFO: Writes flushed. Stopping compactions now...
caddy_1                | badger 2022/05/15 05:52:53 INFO: DropPrefix done
caddy_1                | badger 2022/05/15 05:52:53 INFO: Resuming writes

You’re most likely to get help from the github repo, in the issue you’ve already opened. No need to ask multiple times! darkweak is the mastermind there, so you’ll just need to wait for his answer :slight_smile:

1 Like

my bad! Too much motivation is a bad combo when your stuck haha thanks!