I have a block that displays a product grid with SKUs mention in admin system configuration and I have provided cache lifetime for that block as 3600 sec. It works perfectly fine.

Now when admin makes the changes in SKUs list in admin configuration it does not reflect the updated version immediately. How can I clear that particular block cache after admin saves the SKUs list?

  • you should clear the config cache by command or by admin panel
    – ASQ
    Commented Oct 1, 2019 at 10:08
  • @ASQ, but why should someone clear config cache if I want to just flush cache for this particular block?
    – ANKIT
    Commented Oct 2, 2019 at 2:50

2 Answers 2


Finally, I got a solution:

In your custom block, provide a cache tag for your block by assigning cache_tags a unique value for your block.

e.g. in my case, I will set the tag as cache_tags[] = 'custom_skus'

Or you can implement IdentityInterface in your custom block and then override getIdentities method, which will return array of tags.


public function getIdentities()
    return ['custom_skus_block'];

Now, you can observe the save after of admin config and clean the tags using $this->_cacheManager->clean($tags);. Refer here for event of admin config save.

Hope this helps!

  • the cacheManager is the Magento\Framework\App\CacheInterface Commented Feb 5, 2022 at 23:23

Blocks can be set as non-cacheable by setting the cacheable attribute false in layout XML files. For example

<block class="Block\Class" name="blockname" cacheable="false" />

Pages containing such blocks are not cached.

Also check How do disable caching of custom block

A single cacheable="false" will disable Full Page Caching for the whole page, making the pages sourcing from that layout file extremely slow! Check https://inviqa.com/blog/how-full-page-cache-works-magento-2

  • this will not set the cache for the block; I want cache for block, I just need a way where I can just flush the cache for the particular block. Thanks!
    – ANKIT
    Commented Oct 2, 2019 at 2:48

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.