Skip to content

Commit 3f36fb5

Browse files
committed
Return the 304 response if we do not have a response in cache
1 parent 3b2f720 commit 3f36fb5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/CachePlugin.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
9696

9797
return $next($request)->then(function (ResponseInterface $response) use ($cacheItem) {
9898
if (304 === $response->getStatusCode()) {
99+
if (!$cacheItem->isHit()) {
100+
// We do not have the item in cache. We can return the cached response.
101+
return $response;
102+
}
103+
99104
// The cached response we have is still valid
100105
$data = $cacheItem->get();
101106
$data['expiresAt'] = time() + $this->getMaxAge($response);

0 commit comments

Comments
 (0)