Description
Description
There is currently a new RFC published for cache-control headers specific for CDN's. It was created by 3 authors working at cloudflare, akamai and fastly.
https://datatracker.ietf.org/doc/rfc9213/
I think it would be great if the HttpFoundation make it easier to control this headers so we have the same functionality like we have now for the Cache-Control
header in the Response Class.
Some more links beside the rfc above:
- https://blog.cloudflare.com/cdn-cache-control/
- https://developers.cloudflare.com/cache/about/cdn-cache-control/
- https://www.akamai.com/blog/news/targeted-cache-control
- Twitter Discussion Fastly: https://twitter.com/crucially/status/1557804735419355137
Example
I think the following methods of the HeaderBag
would be effect by an "optional" targeted header variable (CDN-Cache-Control
, Fastly-Cache-Control
, Cloudflare-Cache-Control
):
- addCacheControlDirective
- removeCacheControlDirective
- getCacheControlDirective
- hasCacheControlDirective
The following method on the Response
would also be effected by "optional" header name:
- setMaxAge
- setStaleIfError
- setStaleWhileRevalidate
- setCache
- setPrivate
- setPublic
- isCacheable
- setImmutable?
Why at first way it looks like it make sense the following I think have no effect on -cache-control header:
- setSharedMaxAge (cas aching is set via setMaxAge)
Also the Symfony
Cache itself should keep the "-Cache-Control" header in mind. In general it is mostly a CDN-Cache-Control
and an own name in case of Symfony it would make sense to call it Symfony-Cache-Control
.
This headers make it clearer if the response itself is cachable by a server side cache but maybe not by a client side cache (including private ESI's) currently this kind of controlling was not very transparent and FOSHttpCache did workaround by a custom X-Reverse-Proxy-TTL
which did not support other things like stale-if-error, statle-while-revalidate, ... Original discussion started there some time ago before the RFC was available: FriendsOfSymfony/FOSHttpCache#455.
PS: As seen above the RFC goes with <Targeted>-Cache-Control
while it maybe would first make sense to give only <targeted>
into the methods above. It would be better go give the whole header name into it like CDN-Cache-Control
this make it possible to support none standardized headers like Surrogate-Control
(fastly) and Edge-Control
(akamai) also.
Mention some cache related persons: @dbu, @andrerom, @Toflar