-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Don't send default cache header for 301 redirects #18220
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
Conversation
e-moe
commented
Mar 17, 2016
•
edited by fabpot
Loading
edited by fabpot
Q | A |
---|---|
Branch? | "master" |
Bug fix? | no |
New feature? | yes |
BC breaks? | yes |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #17139 |
License | MIT |
Doc PR | see comments from #17139 |
@@ -41,6 +41,10 @@ public function __construct($url, $status = 302, $headers = array()) | |||
if (!$this->isRedirect()) { | |||
throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status)); | |||
} | |||
|
|||
if (301 == $status && !array_key_exists('cache-control', $headers)) { |
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.
I'm not sure if it's correct place for this code. Looking forward for review
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.
I would instead move this into the main Response class just before sending the headers to the client.
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.
@fabpot, in Response class headers already computed and contains unnecessary 'no-cache' directive. We can't check wether is was set automatically or explicitly by user. see \Symfony\Component\HttpFoundation\ResponseHeaderBag::computeCacheControlValue
probably we can add
then, in
|
I'm going to merge this as is. |
Thank you @e-moe. |
This PR was merged into the 3.2-dev branch. Discussion ---------- Don't send default cache header for 301 redirects | Q | A | ------------- | --- | Branch? | "master" | Bug fix? | no | New feature? | yes | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17139 | License | MIT | Doc PR | see comments from #17139 Commits ------- cf253a9 17139: do not send default cache header for 301 redirects