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

Fix that ESI/SSI processing can turn a "private" response "public"#26643

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
fabpot merged 1 commit intosymfony:2.7frommpdude:fix-cache-public
Apr 16, 2018

Conversation

@mpdude
Copy link
Contributor

@mpdudempdude commentedMar 22, 2018
edited
Loading

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
Doc PR

Under the condition that

  • we are merging in at least oneembedded response,
  • allembedded responses arepublic,
  • themain response isprivate and
  • all responses use expiration-based caching (note: nos-maxage on themain response)

... the resulting response will turn toCache-Control: public.

The real issue is that when all responses use expiration-based caching, a combined max age is computed. This is set on themain response usingResponse::setSharedMaxAge(), which implicitly setsCache-Control: public.

The fix provided in this PR solves the problem by applying the same logic to themain response that is applied forembedded responses, namely that responses with!Response::isCacheable() will make the resulting response haveCache-Control: private, no-cache, must-revalidate and have(s)max-age removed.

This makes the change easy to understand, but makes responses uncacheable too often. This is because theResponse::isCacheable() method was written to determine whether it is safe for a shared cache to keep the response, which is not the case as soon as aprivate response is involved. This might be improved upon in another PR.

@mpdude
Copy link
ContributorAuthor

Ping@aschempp – you wrapped your head around theResponseCacheStrategy lately, so you might want to comment.

@nicolas-grekasnicolas-grekas added this to the2.7 milestoneMar 23, 2018
@aschempp
Copy link
Contributor

The fix looks somewhat correct to me, according to the PR title.

However, the correct solution would be to make the final response private (and not non-cacheable). But I guess you're aware of that and this PR is to disable caching in favor of incorrect caching.

@mpdude
Copy link
ContributorAuthor

@nicolas-grekas The appveyor test failed at

1) Symfony\Component\Console\Tests\Helper\ProcessHelperTest::testVariousProcessRuns with data set #2 ('  RUN  php -r "echo 42;"\n  OU...fully\n', 'php -r "echo 42;"', 4, null)Failed asserting that two strings are equal.--- Expected+++ Actual@@ @@ '  RUN  php -r "echo 42;"-  OUT  42   RES  Command ran successfully 'C:\projects\symfony\src\Symfony\Component\Console\Tests\Helper\ProcessHelperTest.php:33FAILURES!

Is that a known spurious test?

@fabpot
Copy link
Member

Thank you@mpdude.

@fabpotfabpot merged commit3d27b59 intosymfony:2.7Apr 16, 2018
fabpot added a commit that referenced this pull requestApr 16, 2018
…"public" (mpdude)This PR was squashed before being merged into the 2.7 branch (closes#26643).Discussion----------Fix that ESI/SSI processing can turn a "private" response "public"| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |Under the condition that* we are merging in at least one *embedded* response,* all *embedded* responses are `public`,* the *main* response is `private` and* all responses use expiration-based caching (note: no `s-maxage` on the *main* response)... the resulting response will turn to `Cache-Control: public`.The real issue is that when all responses use expiration-based caching, a combined max age is computed. This is set on the *main* response using `Response::setSharedMaxAge()`, which implicitly sets `Cache-Control: public`.The fix provided in this PR solves the problem by applying the same logic to the *main* response that is applied for *embedded* responses, namely that responses with `!Response::isCacheable()` will make the resulting response have `Cache-Control: private, no-cache, must-revalidate` and have `(s)max-age` removed.This makes the change easy to understand, but makes responses uncacheable too often. This is because the `Response::isCacheable()` method was written to determine whether it is safe for a shared cache to keep the response, which is not the case as soon as a `private` response is involved. This might be improved upon in another PR.Commits-------3d27b59 Fix that ESI/SSI processing can turn a \"private\" response \"public\"
@mpdudempdude deleted the fix-cache-public branchApril 17, 2018 08:29
This was referencedApr 27, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

5 participants

@mpdude@aschempp@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp