Skip to content

Commit 78193c4

Browse files
committed
Add optional argument
1 parent ddfbace commit 78193c4

File tree

2 files changed

+8
-269
lines changed

2 files changed

+8
-269
lines changed

src/services/CacheRequestService.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function getIsCacheableResponse(Response $response): bool
201201
return false;
202202
}
203203

204-
return $this->getIsHtmlResponseFormat()
204+
return $this->getIsHtmlResponseFormat($response)
205205
|| Blitz::$plugin->settings->cacheNonHtmlResponses;
206206
}
207207

@@ -759,9 +759,11 @@ private function addCraftHeaders(Response $response): void
759759
}
760760
}
761761

762-
private function getIsHtmlResponseFormat(): bool
762+
private function getIsHtmlResponseFormat(?Response $response = null): bool
763763
{
764-
return in_array(Craft::$app->getResponse()->format, [
764+
$response = $response ?? Craft::$app->getResponse();
765+
766+
return in_array($response->format, [
765767
Response::FORMAT_HTML,
766768
TemplateResponseFormatter::FORMAT,
767769
]);

0 commit comments

Comments
 (0)