Skip to content

Commit 69bd2dd

Browse files
committed
Merge branch '2.3-develop' of https://github.com/mattijv/magento2 into 2.3-develop
2 parents 22b9e56 + e198914 commit 69bd2dd

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

lib/internal/Magento/Framework/App/PageCache/Kernel.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ public function process(\Magento\Framework\App\Response\Http $response)
137137
if (preg_match('/public.*s-maxage=(\d+)/', $response->getHeader('Cache-Control')->getFieldValue(), $matches)) {
138138
$maxAge = $matches[1];
139139
$response->setNoCacheHeaders();
140-
if ($this->shouldCacheResponse($response)) {
140+
if (($response->getHttpResponseCode() == 200 || $response->getHttpResponseCode() == 404)
141+
&& ($this->request->isGet() || $this->request->isHead())
142+
) {
141143
$tagsHeader = $response->getHeader('X-Magento-Tags');
142144
$tags = $tagsHeader ? explode(',', $tagsHeader->getFieldValue()) : [];
143145

@@ -216,22 +218,4 @@ private function getCache()
216218
}
217219
return $this->fullPageCache;
218220
}
219-
220-
/**
221-
* Check if the response should be cached. For GET requests both 200 and 404 responses should be
222-
* cached. For HEAD requests only 200 responses should be cached.
223-
*
224-
* @param \Magento\Framework\App\Response\Http $response
225-
* @return bool
226-
*/
227-
private function shouldCacheResponse(\Magento\Framework\App\Response\Http $response)
228-
{
229-
$responseCode = $response->getHttpResponseCode();
230-
if ($this->request->isGet()) {
231-
return $responseCode == 200 || $responseCode == 404;
232-
} elseif ($this->request->isHead()) {
233-
return $responseCode == 200;
234-
}
235-
return false;
236-
}
237221
}

lib/internal/Magento/Framework/App/Test/Unit/PageCache/KernelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public function testProcessSaveCacheDataProvider()
248248
{
249249
return [
250250
[200, [3, 4, 5]],
251-
[404, [3, 4, 5]]
251+
[404, [4, 5, 6]]
252252
];
253253
}
254254

0 commit comments

Comments
 (0)