-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[HttpKernel] Correctly merge max-age/s-maxage and Expires headers
#58376
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
|
|
||
| yield 'merge max-age and s-maxage' => [ | ||
| ['public' => true, 'max-age' => '60'], | ||
| ['public' => true, 'max-age' => null, 's-maxage' => '60'], |
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.
If one response has max-age and the other has s-maxage, the final response should only have a s-maxage header and no max-age (since we don't know the "private" value for one of the responses).
|
BTW this will cause upstream merge issues because the |
|
Failing test is unrelated (5.4 branch is failing without this PR as well) |
max-age/s-maxage and Expires headers
e6aec6b to
d3e65d6
Compare
|
Thank you @aschempp. |
|
Thank you Andreas |
The
ResponseCacheStrategydoes not currently mergeExpiresandCache-Control: max-age/s-maxageheaders. Before #41665 this was not an issue, because if not all respones had all headers, they were not added to the final reponse. And we could assume a response itself is consistent betweenExpiresandmax-age.@mpdude added heuristic caching of public responses in #41665. Unfortunately, it only looks at
Cache-Control: publicbut if should also check if no cache information (max-age/s-maxage/Expires) is present. If that were the case, the behavior would not have changed. But it now leads to inconsistent header values because it independently keepsExpiresandmax-age/s-maxage.This PR does not only fix the heuristic caching, but also merges
ExpiresandCache-Controlheaders to make sure only the lowest value is retained across all headers. For semi-BC reasons I also made sure to only add anExpiresheader if any of the responses contains one.