Skip to content

Commit b275498

Browse files
committed
Return the 304 response if we do not have a response in cache
1 parent bf26e7d commit b275498

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
@@ -95,6 +95,11 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
9595

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

0 commit comments

Comments
 (0)