I've a mega menu extension which I feel is quite slow. It seems to add about 2 seconds on load time for each page.
As this menu does not change between pages I was wondering how to cache a block? I want it generated just once on the first-page load after a cache flush so that each page can just load the cached block rather than having to repeat for each page on site.
The pages are cached and am not talking about the FPC here as page load is fine when cached but over 15,000 odd pages warming up a cache will save roughly 30,000 seconds if this is not repeated constantly.
Best Answer
I think every block cache in magento,
But if you want to increase
cachelifetime
of particular blockYou can do from your extension's block
go to your block and write below method
this method already there in
Magento\Framework\View\Element\AbstractBlock
The cache lifetime can also be set like so within construct: