cancel
Showing results for 
Search instead for 
Did you mean: 

Cache for your own blocks or widgets

Cache for your own blocks or widgets

In Magento, custom blocks that are extended from Magento\Framework\View\Element\Template are not automatically cached. You must explicitly enable and configure caching for each custom block or widget. If you want to enable caching for a block, you must implement the getCacheLifetime, getCacheKey and getCacheTags methods in your block class. These methods define the cache lifetime, cache key and cache tags for the block.

Is that right? I thought that if a block class is extended from Magento\Framework\View\Element\Template, this custom block or widget is also automatically cached. I thought I didn't have to do anything.

 

Vladimir