Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpKernel] Correctly mergemax-age/s-maxage andExpires 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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@aschempp
Copy link
Contributor

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
IssuesFixcontao/contao#7494
LicenseMIT

TheResponseCacheStrategy 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 addedheuristic caching of public responses in#41665. Unfortunately, it only looks atCache-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 theheuristic caching, but also mergesExpires 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.

fritzmg, Toflar, and mpdude reacted with thumbs up emoji

yield'merge max-age and s-maxage' => [
['public' =>true,'max-age' =>'60'],
['public' =>true,'max-age' =>null,'s-maxage' =>'60'],
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If one response hasmax-age and the other hass-maxage, the final response should only have as-maxage header and nomax-age (since we don't know the "private" value for one of the responses).

chalasr and Toflar reacted with thumbs up emoji
@aschempp
Copy link
ContributorAuthor

BTW this will cause upstream merge issues because theResponseCacheStrategy has received new features in Symfony 6 (see#42355). Not sure how to deal with that, should I open a second PR for Symfony 6?

@aschempp
Copy link
ContributorAuthor

Failing test is unrelated (5.4 branch is failing without this PR as well)

@OskarStarkOskarStark changed the title[HttpKernel] Correctly merge max-age/s-maxage and Expires headers[HttpKernel] Correctly mergemax-age/s-maxage andExpires headersSep 27, 2024
@nicolas-grekas
Copy link
Member

Thank you@aschempp.

@nicolas-grekasnicolas-grekas merged commit908a91f intosymfony:5.4Oct 3, 2024
10 of 12 checks passed
@mpdude
Copy link
Contributor

Thank you Andreas

aschempp reacted with heart emoji

@aschemppaschempp deleted the fix/response-strategy branchOctober 8, 2024 09:31
This was referencedOct 27, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@mtarldmtarldmtarld approved these changes

@chalasrchalasrchalasr approved these changes

+1 more reviewer

@ToflarToflarToflar approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

7 participants

@aschempp@nicolas-grekas@mpdude@Toflar@mtarld@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp