Skip to content

Commit 01ea431

Browse files
committed
Merge pull request #19 from Nyholm/patch-1
Dont respect cache headers when $this->respectCacheHeaders=false
2 parents 09694c3 + 1fa9377 commit 01ea431

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/CachePlugin.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,11 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
8686
*/
8787
protected function isCacheable(ResponseInterface $response)
8888
{
89-
if (!in_array($response->getStatusCode(), [200, 203, 300, 301, 302, 404, 410])) {
90-
return false;
91-
}
92-
if ($this->getCacheControlDirective($response, 'no-store') || $this->getCacheControlDirective($response, 'private')) {
93-
return false;
94-
}
89+
$cachableCodes = [200, 203, 300, 301, 302, 404, 410];
90+
$privateHeaders = $this->getCacheControlDirective($response, 'no-store') || $this->getCacheControlDirective($response, 'private');
9591

96-
return true;
92+
// If http status code is cachable and if we respect the headers, make sure there is no private cache headers.
93+
return in_array($response->getStatusCode(), $cachableCodes) && !($this->respectCacheHeaders && $privateHeaders);
9794
}
9895

9996
/**

0 commit comments

Comments
 (0)