I know this is seem stupid question but I'm a newbie in Magento 2. So I want to ask you guys that Where can I see a different between cacheable ='false' and cacheable='true'?.

I checked in Local Storage in Chrome but it didn't show me anything different.

  • @AnkitShah I know that document, but I need know where we can see the different between its.
    – Henry Bui
    Feb 28, 2017 at 7:02
  • cacheable=false on a block makes whole page not cacheable or Pages containing such blocks are not cached.
    – Jackson
    Feb 28, 2017 at 7:11
  • Yes. Where we can check it has cached or not? I just need an evidence, thanks.
    – Henry Bui
    Feb 28, 2017 at 7:12

3 Answers 3


Let's start at the Magento\Framework\View\Layout::getOutput.
As you may suspect, this transforms the layout to output.
In this method there is a call to renderElement from the same class.
This one renders each element of the page.
In this method, the event core_layout_render_element is dispatched.
And this event is observed by the PageCache module.

<event name="core_layout_render_element">
    <observer name="pagecache" instance="Magento\PageCache\Observer\ProcessLayoutRenderElement" />

Going to the ProcessLayoutRenderElement::execute method you should find this: if ($this->isFullPageCacheEnabled() && $layout->isCacheable()) {

So if the full page cache is enabled and the layout is cachable some hole punching will happen in the generated HTML.

Now let's focus on $layout->isCacheable().
The method looks like this:

public function isCacheable()
    $cacheableXml = !(bool)count($this->getXml()->xpath('//' . Element::TYPE_BLOCK . '[@cacheable="false"]'));
    return $this->cacheable && $cacheableXml;

This means the page layout xml is generated and then Magento looks for a block element in the layout with [@cacheable="false"]. If there is at least one, then the page is not cacheable.

  • Great answer. And if you evaluate $this->getXml()->xpath('//' . Element::TYPE_BLOCK . '[@cacheable="false"]'), it will tell you which block is responsible. Nov 19, 2020 at 19:07

X-Magento-Cache-Debug: MISS shows that the page is never cached. X-Magento-Cache-Debug: HIT this shows the page is cached.

These can be found in the headers of a request refer : https://www.screencast.com/t/epI3jcPKA


You will not see anything different in Local Storage of Chrome, Because in the current context, The block is cached on sever (if cacheable is set to true)

If you want to see the practical difference. leave a comment.

as per your comment, I am giving an example:

1) Go to Stores->configuration->customers->customer configuration->captcha

2) Enable it for login page, refer following settings

enter image description here

3) Enable the cache from admin / using CLI commands.

4) Now go to customer login page and refresh it 4-5 times and see the effect on captcha image.

5) Next open file customer_account_login.xml

6) edit the following code and remove cacheable="false"

<referenceContainer name="form.additional.info">
            <block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
                <action method="setFormId">
                    <argument name="formId" xsi:type="string">user_login</argument>
                <action method="setImgWidth">
                    <argument name="width" xsi:type="string">230</argument>
                <action method="setImgHeight">
                    <argument name="width" xsi:type="string">50</argument>

7) Now flush the cache and see the result after again refreshing multiple times. You will see the captcha is not getting changed properly.

  • Yes bro. I just want to see different between it. Can you help me?
    – Henry Bui
    Mar 2, 2017 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.