Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ public function aroundDispatch(
*/
protected function addDebugHeaders(ResponseHttp $result)
{
$cacheControl = $result->getHeader('Cache-Control')->getFieldValue();
$this->addDebugHeader($result, 'X-Magento-Cache-Control', $cacheControl);
$this->addDebugHeader($result, 'X-Magento-Cache-Debug', 'MISS', true);
$cacheControlHeader = $result->getHeader('Cache-Control');
if ($cacheControlHeader instanceof \Zend\Http\Header\HeaderInterface) {
$cacheControl = $cacheControlHeader->getFieldValue();
$this->addDebugHeader($result, 'X-Magento-Cache-Control', $cacheControl);
$this->addDebugHeader($result, 'X-Magento-Cache-Debug', 'MISS', true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If getHeader() returns false, why should the header 'X-Magento-Cache-Control' not be sent?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in that case there is no Cache-Control header is set. If we set any value to X-Magento-Cache-Control, it may confuse developers that value is set from Magento, unless we can put a very clear message to identify that fact. That is my thinking.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misspoke, I meant X-Magento-Cache-Debug, because it does not rely on the $cacheControl variable. Won't devs still benefit from seeing whether cache was missed? Agree on X-Magento-Cache-Control header

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I have changed the code like that. (not sure why the test is failed for PHP 5.5, but it doesn't related to this fix)

}
return $result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ public function aroundRenderResult(
}

if ($this->state->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
$cacheControl = $response->getHeader('Cache-Control')->getFieldValue();
$response->setHeader('X-Magento-Cache-Control', $cacheControl);
$response->setHeader('X-Magento-Cache-Debug', 'MISS', true);
$cacheControlHeader = $result->getHeader('Cache-Control');
if ($cacheControlHeader instanceof \Zend\Http\Header\HeaderInterface) {
$cacheControl = $cacheControlHeader->getFieldValue();
$response->setHeader('X-Magento-Cache-Control', $cacheControl);
$response->setHeader('X-Magento-Cache-Debug', 'MISS', true);
}
}

$tagsHeader = $response->getHeader('X-Magento-Tags');
Expand Down