-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] [HttpCache] Don't throw on 304 Not Modified #43998
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
Conversation
It looks like you unchecked the "Allow edits from maintainer" box. That is fine, but please note that if you have multiple commits, you'll need to squash your commits into one before this can be merged. Or, you can check the "Allow edits from maintainers" box and the maintainer can squash for you. Cheers! Carsonbot |
@nicolas-grekas Could I get a review on this? |
I'm not sure I get the full consequences of this. Maybe @aschempp could help review? |
For completeness: I provided a minimal reproducer in the PR mentioned above (aleho/symfony-httpcache) Have a look at Esi.php to reproduce the issue. |
Thanks for the ping @nicolas-grekas. The PR sounds valid, but if I understand it correctly it can only ever appear if #42355 gets merged, is that correct @aleho? Also, I'm unsure if HttpCache correctly handles a 304 from an ESI fragment, possibly extending the lifetime of the cache etc, did you maybe check for that? |
Yes, that's right, the problem isn't triggered normally, because But, and this is what this PR is about, you can easily trigger a server 500 by sending the header in a request. Unmodified Symfony with ESI enabled:
Again, this happens with an unmodified Symfony installation and ESI enabled. In my opinion this is a bug, there should be no 500 when sending a request with an "If-Modified-Since" header. In my demo I didn't even return a 304 in any of the controller actions / fragments, I only set a last modified date. |
@aschempp @nicolas-grekas Do you have any new feedback on this? All Symfony versions I tested are still affected. |
IIUC, it needs #42355, which is going to be part of 6.2 (as a new feature). So, I'd suggest to wait for the other PR to merged and then, this one can be added on top for 6.2 as well. |
@fabpot This PR is actually independent of the other one. The 500 can be observed in any Symfony version if the browser sends an |
Thank you @aleho. |
If the response cache keeps a
Last-Modified
header clients will request withIf-Modified-Since
.The surrogate will not handle a
304 Not Modified
correctly, resulting in a 500 and a failed request.This fixes that request / response cycle, as observed in testing PR #42355.