I try to figure out for https://github.com/caddyserver/cache-handler how cache keys are generated or configurable. Use case is to know how to cache a site with some page variations based on cookies (mostly binary combinations like in AB testing or two languages).
I’m not so sure about the difference of the cache_keys and the key directive. The obvious one is that cache_keys allows me to be very specific by matching the URI. But they both share only disable_(body|host|method). And out of a sudden there is talk about GraphQL…
On the other hand headers says in the docs “List of headers to include to the cache” whereas there is a small note in the configuration example at https://github.com/darkweak/souin that says “Default headers concatenated in stored keys”.
So I would “to include in the cache” read as “in the response” and “stored in keys” related to the Cache algo figuring out what variations to return (e.g. three headers, times three variations).
I looked at other caches how cache keys can be computed, for example NGINX has this: proxy_cache_key $scheme$proxy_host$uri$is_args$args;
I assume this is not how the Cache-handler works, there is no explicit Cache-Key option to be configured - or is it? - but a combination of body-host-method-header(s) distributed over keys/header directives?
Hello, in the next release I’ll refactor that, te headers will move inside the cache_keys in addition to disable_(body|host|method) and we will store the header value in the key
e.g.
And you send a request on dummy.domain/account.php with the headers Authorization: fooContent-Type: text/jsonwill give you the key GET-dummy.domain-/account.php-foo-text/json
With souin you cannot really add a business logic on the cache key generation.
I think that should do the trick. Keep in mind that’s not already available in the latest Souin version (but released in few days) and you’ll have to move the map and header directives outside souin configuration (in your matcher)