8000 Symfony 4 : Response head auto add private and max-age=0. How to fix it ? · Issue #25826 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Symfony 4 : Response head auto add private and max-age=0. How to fix it ? #25826

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
askuiop opened this issue Jan 18, 2018 · 6 comments
Closed

Comments

@askuiop
Copy link
askuiop commented Jan 18, 2018

Not all the page use session . so this function is not necessary !

@nicolas-grekas
Copy link
Member

As soon as the session is used once anywhere to generate a response, it becomes non cache able.
You should debug to find where the session is used and figure out a way to not use the session if you want a different Cache-Control.

@pixeltreiber
Copy link
pixeltreiber commented Jan 18, 2018

I did some debugging on the same problem today with symfony 3.4.3 to find out where my session is started. I found that the session is always added to the request by the AbstractSessio 8000 nListener See

In RequestDataCollector::onKernelResponse then the session is always used to find out if the request is a redirect. https://github.com/symfony/symfony/blob/v3.4.0/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php#L319

So I think in my app I can never have a request without an active session.

There is a fix for this in a commit from 10 days ago on the symfony 4 branch. 83f2579
But I guess in your version this is still broken.

@nicolas-grekas
Copy link
Member

@pixeltreiber your correct, this issue in RequestDataCollector is fixed and will be part of the next release, due in 2 weeks now (monthly releases.)
I'm closing here, as we the issue is fixed in the code and doesn't need tracking anymore.

@erichard
Copy link
erichard commented Feb 15, 2018

@nicolas-grekas @fabpot It could be considered as a BC break.

Before Symfony 3.4, my projects had HTTP caching even with a started session and now it doesn't. To fix the problem I have to do a big amount of work:

  • Change firewall pattern as I used '/' with anonymous
  • Fix many kernel listeners that use the session (by converting them to lazy loaded services)

I understand this change but it should only be included in 4.0 IMO

@alterphp
Copy link

Why not sending a deprecation notice in Sf 3.4 instead of adding private cache header ?

@florianajir
Copy link

@nicolas-grekas So how can I use http cache for my API listings protected by oauth token ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
0