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

[HttpFoundation] UseCache-Control: must-revalidate only if explicit lifetime has been given#34438

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
nicolas-grekas merged 1 commit intosymfony:3.4frommpdude:etag-no-must-revalidate
Dec 10, 2019

Conversation

@mpdude
Copy link
Contributor

QA
Branch?3.4
Bug fix?yes
New feature?no
Deprecations?no
Tickets
LicenseMIT
Doc PR

This is really nit-picking: The conservative, safe default forCache-Control isprivate, no-cache which means the response must not be served from cache unless it has been validated.

IfLast-Modified orExpires are present, we can relaxno-cache to bemust-revalidate, which means thatonce the response has become stale, it must be revalidated.

AnETag alone does not give the response a lifetime, so IMO sticking withno-cache in this case would be more consistent.

@mpdudempdude changed the titleDon't change to Cache-Control: private, must-revalidate if only the ETag is present[HttpFoundation] UseCache-Control: must-revalidate only if explicit lifetime has been givenNov 18, 2019
@derrabus
Copy link
Member

AnETag alone does not give the response a lifetime

Last-Modified doesn't either, does it?

@mpdude
Copy link
ContributorAuthor

mpdude commentedNov 18, 2019
edited
Loading

TIL that if the status code iscacheable by default or a response without explicit freshness has been marked as explicitly cacheable (e.g., with apublic response directive), thenheuristic freshness based onLast-Modified may be applied.

Until now, I always thought this was a browser quirk.

@nicolas-grekas
Copy link
Member

Should the PR target 3.4?

@nicolas-grekasnicolas-grekas added this to the3.4 milestoneNov 18, 2019
@nicolas-grekas
Copy link
Member

I don't understand the change. When there is an ETag, we should sendprivate, must-revalidate, because that's what an ETag allows: revalidation.

@mpdude
Copy link
ContributorAuthor

no-cache is the default, which tells a cache that itmust revalidate the resource uponevery request.must-revalidate means that revalidation must occuronce the response has become stale.

As anETag alone does not define a lifetime, my suggestion was to switch fromno-cache tomust-revalidate only if a header is present that defines the lifetime (asExpires orCache-Control: max-age=...) or that allows for a heuristic expiration to be applied (Last-Modified is provided).

Nit-picking, really.

@mpdude
Copy link
ContributorAuthor

I agree the RFC might have chosen more intention-revealing names.

@nicolas-grekas
Copy link
Member

An ETag without a lifetime is considered as having a zero lifetime by browsers AFAIK.
I don't think no-cache is appropriate: a conditional request is possible today and works, whereas this change would kill this conditional request.

@mpdude
Copy link
ContributorAuthor

No, it would not.

If the lifetime is considered to be zero,no-cache andmust-revalidate would have the same effect, namely that a revalidation has to happen right from the start/after 0 seconds.

no-store: Prohibits caching, thus no revalidation/conditional requests.

no-cache: Response can be cached, but must be revalidated every time.

must-revalidate: Response may be used without validation as long as it is fresh; must be revalidated afterwards and must not be used when stale.

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedNov 28, 2019
edited
Loading

Oh, so no-cache <=> must-revalidate,maxage=0 got it. Works then.

@fabpot
Copy link
Member

Tests do not pass apparently.

@mpdude
Copy link
ContributorAuthor

Failing tests come fromResponseCacheStrategy (here).

With the change from this PR, we now haveCache-Control: no-cache in some cases where previously we hadCache-Control: must-revalidate.

If this change applies to an ESI subrequest,ResponseCacheStrategy now decides (here) that the resulting, ESI-tags-merged response can no longer be cached using the expiration model (here).

It thus adds anExpires header and sets it to the responseDate. This is where the tests break: Now the lifetime is0, previously it wasnull.

I need to think through theResponseCacheStrategy behaviour because itfeels as if there might be a bug. The change here should not make a difference for the decision if something is cacheable or not.

Second, I'll try to remove theExpires header which IMO is not really necessary; not having it might already make tests pass again.

TL;DR: Working on it ;-)

@mpdude
Copy link
ContributorAuthor

Maybe@nicolas-grekas can confirm that thedeps=high build failure is due to the change being in one component, the fix for the test in another one?

@nicolas-grekasnicolas-grekas changed the base branch frommaster to3.4December 10, 2019 08:49
@nicolas-grekas
Copy link
Member

Thank you@mpdude.

nicolas-grekas added a commit that referenced this pull requestDec 10, 2019
… if explicit lifetime has been given (mpdude)This PR was merged into the 3.4 branch.Discussion----------[HttpFoundation] Use `Cache-Control: must-revalidate` only if explicit lifetime has been given| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       || License       | MIT| Doc PR        |This is really nit-picking: The conservative, safe default for `Cache-Control` is `private, no-cache` which means the response must not be served from cache unless it has been validated.If `Last-Modified` or `Expires` are present, we can relax `no-cache` to be `must-revalidate`, which means that _once the response has become stale_, it must be revalidated.An `ETag` alone does not give the response a lifetime, so IMO sticking with `no-cache` in this case would be more consistent.Commits-------1b1002b [HttpFoundation] Use `Cache-Control: must-revalidate` only if explicit lifetime has been given
@nicolas-grekasnicolas-grekas merged commit1b1002b intosymfony:3.4Dec 10, 2019
This was referencedDec 19, 2019
This was referencedJan 21, 2020
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

3.4

Development

Successfully merging this pull request may close these issues.

5 participants

@mpdude@derrabus@nicolas-grekas@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp