Most common issue is a block included in all pages with cacheable = false.
Maybe an extension with this declaration in default.xml.
See vendor/magento/framework/View/Layout.php
, function isCacheable.
In particular:
`$this->getXml()->xpath('//' . Element::TYPE_BLOCK . '[@cacheable="false"]')`
To debug page load and save, see bellow. But before it, I would start with the above.
The page is loaded/saved from page cache type with these entry points:
vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php
vendor/magento/module-page-cache/Model/Controller/Result/BuiltinPlugin.php
This class is an around plugin on vendor/magento/framework/View/Result/Layout.php
, renderResult
function. Layout is a more complex version of vendor/magento/framework/Controller/Result/Raw.php
. Raw
builds a page in a string ($content = 'All that it is';
). Layout builds the page using XML layout (a tree of blocks/ a tree of strings).
All plugins contain straight forward code and there is no need for further code explanation.
Cache is HIT
when the page is found in cache. If not in cache, than it allows the application to build the content (html; there is a check that JSON should not be cached, ..) and saves in cache page's html for the next time.
In the 2 plugins (FrontController mostly) you can start debugging and see when it fails. The cause of your issue will be exposed by other parts of the code and to me it looks like it's caused by your setup.
If anything, there is a fix in Kernel.php
https://github.com/magento/magento2/commit/861f596371825d9e24672cd613229ae9486c635f
I personally find it odd.