Skip to content

Commit cd5b817

Browse files
committed
refactor: don't make cahce if $ttl is 0
1 parent fd4e951 commit cd5b817

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

system/Cache/ResponseCache.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ public function __construct(CacheConfig $config, CacheInterface $cache)
5252
$this->cache = $cache;
5353
}
5454

55-
public function getTtl(): int
56-
{
57-
return $this->ttl;
58-
}
59-
6055
/**
6156
* @return $this
6257
*/
@@ -90,12 +85,16 @@ public function generateCacheKey($request): string
9085
}
9186

9287
/**
93-
* Caches the full response from the current request.
88+
* Caches the response.
9489
*
9590
* @param CLIRequest|IncomingRequest $request
9691
*/
9792
public function make($request, ResponseInterface $response): bool
9893
{
94+
if ($this->ttl === 0) {
95+
return true;
96+
}
97+
9998
$headers = [];
10099

101100
foreach ($response->headers() as $header) {

system/CodeIgniter.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,7 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
527527
// Cache it without the performance metrics replaced
528528
// so that we can have live speed updates along the way.
529529
// Must be run after filters to preserve the Response headers.
530-
if ($this->pageCache->getTtl() > 0) {
531-
$this->pageCache->make($this->request, $this->response);
532-
}
530+
$this->pageCache->make($this->request, $this->response);
533531

534532
// Update the performance metrics
535533
$body = $this->response->getBody();

0 commit comments

Comments
 (0)