I have a block which basically serves 3 sections of a page. I want to cache the respective block but one of the section doesn't need to be cached. I am new to Magento and even newer to the caching part of it. I've overwrote the getCacheKey() and getCacheTags()to have some custom functionality. Is there a way to partially cache a block?
1 Answer
Use below snippet in your block file to cache content.
$cacheId = "your_custom_cache_unique_name";
$html = Mage::app()->loadCache($cacheId);
if (!$html) {
$html = $this->renderView(); // Set appropriate data here..
Mage::app()->saveCache($html, $cacheId);
}
return $html;
If you are having multi-store website, you can use
$cacheId = "your_custom_cache_unique_name_".Mage::app()->getStore()->getCode();