Provide a way to cache early hints
Not sure if this is even within the scope of this library, but what would be nice is a way to cache early hints.
For context, I am discovering that caching whole responses is a lot more complicated than I anticipated (mostly issues with things like accidentally caching set-cookie and such)
However, a quick win that should be safe to have enabled for most URLs is to simply cache early hints.
If you can add the HTTP response Cache-Control header with the value Set-Cookie, it won't store the cookie.
e.g. With the Caddyfile
{
admin localhost:2999
http_port 9080
cache {
ttl 5s
}
}
localhost:9080 {
route /cache-set-cookie {
cache
reverse_proxy localhost:9087 {
header_down +Cache-Control no-cache=Set-Cookie
}
}
}
This might be a response to a different thread.
You're right, I opened your issue in another tab, sorry. It can cache the early hints as-is but it will probably wait for the whole content and override the stored response with the final HTTP code and the full response body.
What we could add is a key that match the following pattern {generated_key}_status103_{iteration} and serve all iterations as 103 early hint responses then serve the matched response in cache after.
What we could add is a key that match the following pattern {generated_key}status103{iteration} and serve all iterations as 103 early hint responses then serve the matched response in cache after.
That would be an awesome feature.
I currently built a hacky solution using Fastify, but it would be nice to have as part of the Caddy cache layer.