Purging will purge surrogate_keys but it will still load cached
TNAJanssen opened this issue · 6 comments
Hi,
When i purge using Surrogate keys, it will disappear from /souin/surrogate_keys but not from /souin and when i request the url it will still load from the cache.
This is my local Caddyfile:
{
order cache before rewrite
log {
level debug
}
cache {
api {
basepath /__cache
souin {
basepath /souin
}
}
}
}
localhost:4001 {
cache {
key {
disable_body
disable_host
disable_method
headers Content-Type Authorization
hide
}
cdn {
dynamic
provider default
}
ttl 1000s
timeout {
backend 10s
cache 100ms
}
log_level debug
}
reverse_proxy localhost:8000
}
What can i do to check why this happens? Thanks!
Hello @TNAJanssen I saw your comment here caddyserver/cache-handler#26 (comment). I'm on it on this PR #455 to fix that in the core HTTP cache.
I assume you still get the STALE_{your key}
in the keys list (/souin-api/souin
).
Hi @darkweak,
I can provide you with all the outputs if you like, but the /surrogate_keys only holds the STALE_{key} but the /souin will still hold STALE_{key} and {key} and nothing is purged. When removing the key from Redis for example it will load the data again.
What can i do to help?
After loading a page that get cached these are the results:
/souin
[
"GET-https-/api/00000000-0000-0000-0000-000000000000/relations/00000000-0000-0000-0000-000000000001-application/ld+json--00000000-0000-0000-0000-000000000002{-VARY-}Accept:;Content-Type:application/ld+json;Authorization:;Origin:;Api-Key:00000000-0000-0000-0000-000000000002",
"STALE_GET-https-/api/00000000-0000-0000-0000-000000000000/relations/00000000-0000-0000-0000-000000000001-application/ld+json--00000000-0000-0000-0000-000000000002{-VARY-}Accept:;Content-Type:application/ld+json;Authorization:;Origin:;Api-Key:00000000-0000-0000-0000-000000000002"
]
And surrogate_keys
{
"/api/00000000-0000-0000-0000-000000000000/relations/private/00000000-0000-0000-0000-000000000001": ",GET-https-%2Fapi%2F00000000-0000-0000-0000-000000000000%2Frelations%2F00000000-0000-0000-0000-000000000001-application%2Fld%2Bjson--00000000-0000-0000-0000-000000000002%7B-VARY-%7DAccept%3A%3BContent-Type%3Aapplication%2Fld%2Bjson%3BAuthorization%3A%3BOrigin%3A%3BApi-Key%3A00000000-0000-0000-0000-000000000002",
"STALE_/api/00000000-0000-0000-0000-000000000000/relations/private/00000000-0000-0000-0000-000000000001": ",STALE_GET-https-%2Fapi%2F00000000-0000-0000-0000-000000000000%2Frelations%2F00000000-0000-0000-0000-000000000001-application%2Fld%2Bjson--00000000-0000-0000-0000-000000000002%7B-VARY-%7DAccept%3A%3BContent-Type%3Aapplication%2Fld%2Bjson%3BAuthorization%3A%3BOrigin%3A%3BApi-Key%3A00000000-0000-0000-0000-000000000002"
}
And after i purge the surrogate key: /api/ca9d98c3-0acb-4760-a63a-61aae5592d7a/relations/private/feecaf7a-55af-409c-9539-906f76fecfa1
The API's will give me the following results:
[
"GET-https-/api/00000000-0000-0000-0000-000000000000/relations/00000000-0000-0000-0000-000000000001-application/ld+json--00000000-0000-0000-0000-000000000002{-VARY-}Accept:;Content-Type:application/ld+json;Authorization:;Origin:;Api-Key:00000000-0000-0000-0000-000000000002",
"STALE_GET-https-/api/00000000-0000-0000-0000-000000000000/relations/00000000-0000-0000-0000-000000000001-application/ld+json--00000000-0000-0000-0000-000000000002{-VARY-}Accept:;Content-Type:application/ld+json;Authorization:;Origin:;Api-Key:00000000-0000-0000-0000-000000000002"
]
and surrogate_keys
{
"STALE_/api/00000000-0000-0000-0000-000000000000/relations/private/00000000-0000-0000-0000-000000000001": ",STALE_GET-https-%2Fapi%2F00000000-0000-0000-0000-000000000000%2Frelations%2F00000000-0000-0000-0000-000000000001-application%2Fld%2Bjson--00000000-0000-0000-0000-000000000002%7B-VARY-%7DAccept%3A%3BContent-Type%3Aapplication%2Fld%2Bjson%3BAuthorization%3A%3BOrigin%3A%3BApi-Key%3A00000000-0000-0000-0000-000000000002"
}
@TNAJanssen Can you try the PR before I merge it to be sure it solves your issue?
Using xcaddy build --with GitHub.com/darkweak/souin/plugins/caddy@55c27a0642bb6f796f29c55e47d0609b8a37fbb9 --with GitHub.com/darkweak/souin@55c27a0642bb6f796f29c55e47d0609b8a37fbb9
Yes, i will try it in a couple of hours! Thanks
After purging, it indeed does reload from the server! Good work!