-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
@@ -371,7 +429,7 @@ public static function cacheControlMergingProvider() | |||
]; | |||
|
|||
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
ResponseCacheStrategy
does not currently mergeExpires
andCache-Control: max-age/s-maxage
headers. 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 betweenExpires
andmax-age
.@mpdude added heuristic caching of public responses in #41665. Unfortunately, it only looks at
Cache-Control: public
but 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 keepsExpires
andmax-age/s-maxage
.This PR does not only fix the heuristic caching, but also merges
Expires
andCache-Control
headers to make sure only the lowest value is retained across all headers. For semi-BC reasons I also made sure to only add anExpires
header if any of the responses contains one.