Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[HttpKernel] Do not superseed private cache-control when no-store is set#60569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[HttpKernel] Do not superseed private cache-control when no-store is set#60569
Conversation
252be50
to3f1c717
CompareI'm not sure here. I get your point about "magic", but.. itdoes supersede the private header as, according to theRFC, a cache MUST not store any content with the no-store header. So.. as i read it, no-store/public is not something we should allow here. And there is some similar behaviour in thesetSharedMaxAge method of HttpFoundation/Response Did i missread or missunderstood something here ? |
alexander-schranz commentedMay 28, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@smnandre I sure understand your point and I know why you did implement it as I'm familiar with the RFC :). But in combination with server side caching and still control browsers handling and combinations of ESI this still a validtemporary state for the cache control headers. So you have a response which should be cached but it includes a ESI which should not be cached and requires no-store. In that case for service side caches (symfony or varnish) the response in our case is still public because else the symfony http cache and the fos http cache is skipped and dont cache it. ESI can not manipulate the original cache headers so the controller tells it to be no-store if required by such ESI, but as we still want to cache the original response it still flagged as The max-age I know does the same something which we can sure not change because of BC reasons (personally would also have avoided that), but for the no-store we could still avoid such untransparent handling. |
alexander-schranz commentedMay 28, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
PS: If Symfony want to go the way of say we want to be strict about the RFC. It maybe would be better the handling is in the http foundation and not in the attribute listener. And so |
@@ -165,7 +165,6 @@ public function onKernelResponse(ResponseEvent $event): void | |||
} | |||
if (true === $cache->noStore) { | |||
$response->setPrivate(); |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
And so $response->headers->addCacheControlDirective('no-store'); would already set the response to private
I agree with that approach, the listener is not the correct place anyway for implementing such correlation
Thanks@alexander-schranz for this detailed explanation, makes perfect sense now! |
3f1c717
to7e6e33e
CompareThank you@alexander-schranz. |
8c89e4c
intosymfony:7.4Uh oh!
There was an error while loading.Please reload this page.
Should this not be target to 7.3? |
…o-store is set (alexander-schranz)Discussion----------[HttpKernel] Do not superseed private cache-control when no-store is set| Q | A| ------------- | ---| Branch? | 7.3| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues | -| License | MITI don't think its a good idea to superseed the private cache control via the new noStore option*#59301If somebody want to set it to `private` they should explicit do it. via `#[Cache(private: true, noStore: true)]`. I would avoid this non transparent changes in general.I had usecases in the past where the response is still public for the symfony cache and varnish public and the no store was only for the third party caches and in browser caches. This specially come into play with usage of `ESI` where the general page is cached, but no-store set to not allow back forwards caches, because of the ESI content./cc `@smnandre`Commits-------7e6e33e [HttpKernel] Do not superseed private cache-control when no-store is set
Merged on 7.3 as158dff8 |
Uh oh!
There was an error while loading.Please reload this page.
I don't think its a good idea to superseed the private cache control via the new noStore option
noStore
argument to the#
attribute #59301If somebody want to set it to
private
they should explicit do it. via#[Cache(private: true, noStore: true)]
. I would avoid this non transparent changes in general.I had usecases in the past where the response is still public for the symfony cache and varnish public and the no store was only for the third party caches and in browser caches. This specially come into play with usage of
ESI
where the general page is cached, but no-store set to not allow back forwards caches, because of the ESI content./cc@smnandre