Question

I am using Magento EE 2.1.1 and FPC is enabled (built-in).

What I suppose is, if any page(homepage, category or product pages) is accessed next time, Magento should dispatch whole page content from the cache. But this is not happening. I can see many individual blocks are getting rendered.

Can anyone shed some light on it, please?

  • Is it normal behaviour? or a bug in Magento EE 2.1.1
  • Will full page only be cached in the case of Varnish instead of built-in FPC?

NOTE: The value of HTTP header X-Magento-Cache-Debug is always MISS

Was it helpful?

Solution

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.

OTHER TIPS

If the bin/magento command will tell you the full page cache is enabled and the admin displays it as disabled you may just need to restart php-fpm to reload the OPcache since its loading that setting from the filesystem. The .env file also tells Magento to set the right varnish headers and if it's not loading that the full page cache won't work properly.

Sometimes I've had an extension installation set the full page cache setting in the .env file to 0 instead of 1. Making cacheable page load times go from sub 100ms to over 1000ms.

Make sure the .env file has 'full_page' => 1, then reload php-fpm or if you need it immediately restart php-fpm

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top