I have tried to get update value without caching block.

I have tried all below code,but they are not work.

public function getCacheLifetime()
    return null;

        'cache_lifetime' => 0,
        'cache_tags' => [\Magento\Store\Model\Store::CACHE_TAG, \Magento\Cms\Model\Block::CACHE_TAG]]);

 public function getCacheLifetime()
 return null;


How to disable the cache for block?

thanks in advance.

  • Please share which block you want to remove from the cache.
    – Msquare
    Nov 10, 2022 at 5:49

1 Answer 1


Locate the relevant block or referenceBlock node in your layout XML file and set the cacheable attribute to false.

It should be noted that this will DISABLE FPC for ALL pages that the layout XML in question applies to. Looking at the cache tags in your code this looks like it might be all CMS pages, which would not be ideal.

What is it you are trying to avoid caching? It may be better to achieve the required functionality by utilising Private Content.

If this is the correct answer please mark it "accepted" as it makes it easier for others with the same issue to find the answer.

  • I can not use cacheable=false ,is there other solution ? Nov 9, 2022 at 3:54
  • Is there a reason for that @JigsParmar? What is it you are trying to prevent being cached?
    – Craig
    Nov 9, 2022 at 15:19
  • above code tried to prevent cache. Nov 10, 2022 at 9:13

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.