-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[HttpKernel] Be smarter when merging cache directives in HttpCache/ResponseCacheStrategy #26352
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
Closed
nicolas-grekas
wants to merge
2
commits into
symfony:3.4
from
nicolas-grekas:http-cache-merge-directives
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what about the max age allowing client-side caching ?
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.
let's say we don't care, we don't have to be that smart?
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.
well, allowing private caching without telling the browser how long it can cache it is broken: it won't allow caching in well-behaving browsers (and may allow infinite caching if a crappy browser treats the absence of age on the response as an invitation to cache forever instead of for 0s).
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.
client side caching can have 2 modes: expiration-based (caching for a timestamp) and validation-based (asking whether the last-modified or the etag they have is still the right one).
When using ESI or SSI (which this code is about), we don't send an Etag or LastModified (which this class is handling) because we cannot build them properly when the final response is built based on embedded responses. So this only leaves the expiration-based caching client-side. If you don't care about it, close your PR as it brings nothing.
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.
I'm about to create unit tests to validate that case so we can implement the re 10000 quired checks.
Actually we could do that by generating an ETag based on the complete response. Something like a hash of the whole content. But I think that's for another PR if we want to add that at all.
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.
see nicolas-grekas#13
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.
not helpful, as we could still not use Etag validation of the different sub-requests as we would not have Etags for each of them (unless we build the final Etag as a reversible combination of info about each response), and so we could not perform Etag validation in the controllers generating each subresponse.