Posted almost 10 years ago. Visible to the public.

Block Caching

To cache a block individually, add this method to the blocks class:

Copy
protected function _construct() { $this->addData(array( 'cache_lifetime' => 3600, 'cache_tags' => array(Mage_Cms_Model_Block::CACHE_TAG), 'cache_key' => 'CACHE_KEY', )); }

Note - if you set cache_lifetime to 0 (or any other value which PHP evaluates to false) then the cache will actually last 7200 seconds (2 hours), so in order to have a very high cache time then the cache_lifetime should be set to anything up to 9999999999 (about 317 years)

Owner of this card:

Avatar
Mike Whitby
Last edit:
about 8 years ago
Posted by Mike Whitby to Magento
This website uses short-lived cookies to improve usability.
Accept or learn more