-
Notifications
You must be signed in to change notification settings - Fork 6
Dont respect cache headers when $this->respectCacheHeaders=false #19
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
@@ -89,7 +89,9 @@ protected function isCacheable(ResponseInterface $response) | |||
if (!in_array($response->getStatusCode(), [200, 203, 300, 301, 302, 404, 410])) { | |||
return false; | |||
} | |||
if ($this->getCacheControlDirective($response, 'no-store') || $this->getCacheControlDirective($response, 'private')) { | |||
if ($this->respectCacheHeaders && |
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 think that this check could be in one return statement.
I've updated the PR according to your comments |
Actually I meant the first condition as well. 😄 You could set some helper variables (like the status code list). |
This could go into a separate method, like |
ah. Okey. =) I'll update again and make sure it is readable. |
hm, okey. I put it in a variable now since it not reused. |
|
||
return true; | ||
// If http status code is cachable and if we respect the headers, make sure there is no private cache headers. | ||
return in_array($response->getStatusCode(), $cachableCodes) && (!$this->respectCacheHeaders || !$privateHeaders); |
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.
Hm...
Isn't it the same as !($this->respectCacheHeaders && $privateHeaders)
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.
It is the same according to De Morgan's law. You are correct.
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.
De Morgan's law
I knew that there is a name for this, but I couldn't recall.
Thanks @Nyholm |
Dont respect cache headers when $this->respectCacheHeaders=false
Thank you for merging. |
|
||
return true; | ||
// If http status code is cachable and if we respect the headers, make sure there is no private cache headers. | ||
return in_array($response->getStatusCode(), $cachableCodes) && !($this->respectCacheHeaders && $privateHeaders); |
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 think the previous code with early returns was more readable. i will do another small PR :-)
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 #22
No description provided.