3

I'm trying to switch off caching in referenceBlock. I tried:

<referenceBlock name="block.name">
    <arguments>
        <argument name="cacheable" xsi:type="boolean">false</argument>
    </arguments>
</referenceBlock>

and

<referenceBlock name="wp.homepage.view" cacheable="false"/>

But none of this is working

1
  • have you working below code for u? Aug 1, 2016 at 8:35

1 Answer 1

1

You have to define cacheable="false" within <block> not <referenceBlock>. According to the README for the core PageCache module:

Blocks can also be set as non-cacheable by setting the 'cacheable' attribute in layout XML files.

For example <block class="Block\Class" name="blockname" cacheable="false" />. Pages containing such blocks are not cached.

For example:

<block class="Package\Module\Block\Test" name="block.name" template="Package_Module::test.phtml" cacheable="false"/>

The referenceBlock tag does not support the cacheable attribute.

Thanks.

7
  • 1
    This is not totally right. The referenceBlock does not support cacheable as an attribute but the way the OP tries to use it is totally valid. Aug 1, 2016 at 9:31
  • can you give me any demo for refereneBlock with cacheable support in magento2? plz if you not know well then not comment plz for cacheble. Aug 1, 2016 at 9:32
  • it is possible to change the block template attribute like this: magento.stackexchange.com/a/86198/2380 so it is definitely possible to change the cacheable attribute the same way Aug 1, 2016 at 9:37
  • @raphael, I haven't seen any demo which support cacheable for referenceBlock, and above given link, have you any answer then plz post so other users can helpful. Here user having issue so you can add answer if possible, i think its not working Aug 1, 2016 at 9:40
  • see the duplicate question the answer is from a developer from the team ;) Aug 1, 2016 at 9:45

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