Magento 2: Full Page Cache issues
Written by: Tom Dollar, On: Thursday 17th November 2016
We’ve been working on several Magento 2 sites recently which had an issue with the full page cache not doing its job correctly. Despite being enabled, the full page cache files in /var/page_cache/ contained header information only.The cause?...
The cause? It is usually down to the use of this tag in a layout xml document;
If any element on the page has this tag set, then the whole page will fail to generate full page cache.Is it a bug? Is it a feature?
Is it a bug? Is it a feature? At this stage we will put it down to a bug as Magento’s documentation states this is a safe way to isolate a specific element from being cached. Hopefully it will be resolved in future releases, but that doesn’t help us for now, so here's the fix;
Remove cacheable=false from the offending XML layout document. Now go and find the block constructor class for the block you are trying to make non-cacheable.
In the __construct function add;
$this->_isScopePrivate = true;
Full page cache will now work, while your block remains dynamic.