You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently trying to integrate souin as a caddy module for the api-platform distribution.
Integration with xcaddy build works fine, and I managed to hit some cache quite easily.
I have some issues concerning invalidation through surrogate keys when using the cdn default (souin) provider.
It seems that no surrogate keys are stored, hence making purging irrelevant.
The workflow I setup is the following:
POST a resource (in this case a "Greeting")
GET said resource ( GET https://localhost/greetings/1 ). First call misses cache, subsequent ones hit flawlessly
At this point, GET https://localhost/souin-api/souin/ returns a list of cached keys, but GET https://localhost/souin-api/souin/surrogate_keys returns an empty list
Purging through surrogate keys ( PURGE https://localhost/souin-api/souin/ with the headers { "Surrogate-Key": "/greetings, /greetings/1" } ) returns a 204, but since I believe no key was stored in the first place, it does not have a real impact on the cache itself
Purging the "non-surrogate" cache keys with PURGE https://localhost/souin-api/souin//greetings/1 does work but it is not the path we'd prefer to chose.
Here is my current Caddyfile:
{
order cache before rewrite
debug
log {
level debug
}
cache {
allowed_http_verbs GET POST
api {
souin
}
cdn {
provider default # I also tried with provider souin
}
nuts { # I also tried with badger
path /tmp/nuts
}
log_level debug
key {
disable_host
disable_method
}
ttl 1000s
timeout {
backend 10s
cache 100ms
}
default_cache_control public
}
}
{$SERVER_NAME}
log {
level debug
}
cache * {
}
... + base ApiPlatform stuff, Vulcain + Mercure etc
I was wondering if I was missing anything configuration-wise, or even if I misunderstood completely the way we're supposed to integrate surrogate keys.
Thanks in advance for your help, if I can provide more details I'll be happy to !
PS: I am far from fluent in go, but if there is a PR to make i could also give it a try !
The text was updated successfully, but these errors were encountered:
Hello @JacquesDurand I think the documentation is not clear enough. In the cdn directive you have to set the dynamic directive because without that Souin only handles predefined keys. Maybe we could set the dynamic to true by default in the plugins/caddy/configuration.go file, it could be a quick win.
In your configuration example that would be
# previous
cdn {
dynamic
# Provider not needed, that's souin by default
# provider default
}
Hi @darkweak, thanks for the quick answer ! I just tested it and it does work with the "dynamic" option.
Thanks a lot !
If that's okay with you I can try to make a PR asap to set "dynamic" to true by default in the caddy configuration
Hi !
I am currently trying to integrate souin as a caddy module for the api-platform distribution.
Integration with
xcaddy build
works fine, and I managed to hit some cache quite easily.I have some issues concerning invalidation through surrogate keys when using the cdn default (souin) provider.
It seems that no surrogate keys are stored, hence making purging irrelevant.
The workflow I setup is the following:
GET https://localhost/greetings/1
). First call misses cache, subsequent ones hit flawlesslyGET https://localhost/souin-api/souin/
returns a list of cached keys, butGET https://localhost/souin-api/souin/surrogate_keys
returns an empty listPURGE https://localhost/souin-api/souin/
with the headers { "Surrogate-Key": "/greetings, /greetings/1" } ) returns a 204, but since I believe no key was stored in the first place, it does not have a real impact on the cache itselfHere is my current Caddyfile:
I was wondering if I was missing anything configuration-wise, or even if I misunderstood completely the way we're supposed to integrate surrogate keys.
Thanks in advance for your help, if I can provide more details I'll be happy to !
PS: I am far from fluent in go, but if there is a PR to make i could also give it a try !
The text was updated successfully, but these errors were encountered: