-
Notifications
You must be signed in to change notification settings - Fork 25
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
Cache only valid responses #531
Cache only valid responses #531
Conversation
5ec7828
to
f5c6b83
Compare
@schlessera Any chance to get this merged? This is quite urgent for us, because all our amp pages are invalid without this fix (see #530 ). |
cc @westonruter |
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.
LGTM
@@ -132,7 +132,7 @@ static function ($curl, $header) use (&$headers) { | |||
$curlErrno = curl_errno($curlHandle); | |||
curl_close($curlHandle); | |||
|
|||
if ($body === false) { | |||
if ($body === false || $status < 200 || $status >= 300) { |
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.
This should work as expected, but note that I believe $status
could be 0
. In this case, $body
should also be false
.
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.
Hey! I am not sure, if I understand you correctly. Is there anything to do left?
If $status
can be 0
, it should IMHO be treated as error. And this code does that (smaller than 200
).
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.
Yeah, I'm saying the same thing. In the error case, $status
should be 0
and it will work as expected.
Hi!
Recently we discovered that some requests to fetch the metadata failed, but were cached regardless of the status code. This PR adds a guard, that only valid responses are cached.
This fixes #530