Skip to content

Use sha1 to reduce the risk of collisions #12

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

Merged
merged 7 commits into from
Aug 2, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Only cache if the max age is positive
  • Loading branch information
GrahamCampbell authored Aug 1, 2016
commit 5d3d98ccc02cead7724955447abe7f3ba6091fe8
4 changes: 2 additions & 2 deletions src/CachePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
}

return $next($request)->then(function (ResponseInterface $response) use ($cacheItem) {
if ($this->isCacheable($response)) {
if ($this->isCacheable($response) && ($maxAge = $this->getMaxAge($response)) > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this from another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err, oops...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this from the github online editor, lol.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😝

$bodyStream = $response->getBody();
$body = $bodyStream->__toString();
if ($bodyStream->isSeekable()) {
Expand All @@ -87,7 +87,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
}

$cacheItem->set(['response' => $response, 'body' => $body])
->expiresAfter($this->getMaxAge($response));
->expiresAfter($maxAge);
$this->pool->save($cacheItem);
}

Expand Down