Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpFoundation] Support for RFC9213 Targeted HTTP Cache Control #47288

Open
@alexander-schranz

Description

@alexander-schranz

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:

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions