[5.x] Set etag and lastModified if available #11441
Open
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.
This change will add the etag header to every page response, allowing browsers and more to determine wether their file is still fresh.
And in case of an updated_at being available set the last modified header.
see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified
This would allow crawlers to adjust their crawl frequency on pages not often updated.
And allow browsers to determine wether their page is fresh.
However if the browser supports an etag that will be used instead.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching#heuristic_caching:~:text=Note%3A%20RFC9110%20prefers%20that%20servers%20send%20both%20ETag%20and%20Last%2DModified
This PR differs a lot compared to #11430
as this is not meant to let CDN's or other parties in-between cache pages as it still sends
private, must-revalidate
https://github.com/symfony/symfony/blob/6f4f04b98f6134996a57d21d1851d558a34dc45c/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php#L246
Instead this is meant to support revalidation instead of never being allowed to serve from browser cache.
They will function together without any problems though.