0

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?

Marius
199k55 gold badges431 silver badges837 bronze badges
asked Sep 19, 2014 at 10:37

1 Answer 1

1

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();
answered Sep 19, 2014 at 13:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.