The problem is that I have a News and Updates feed on my homepage and it is causing my ip to call the site an excessive amount of times over the day and causes the server to crash if the site is busy (at least that is what I suspect the problem to be). A way I have thought of solving the problem is in Magento for my custom-blog-feed to come from the cache if exists in there. If not then it will run the function the normal way.

My question is how do I get Magento to look for it in the cache and if it finds it display the feeds if not then the function will come in to play and bring them in.

I am sorry if I haven't explained this too well as I do not 100% know if this is even possible but its the only thing I can think of to solve my problem. Let me know what other information you may need to help answer this question & I apologies if its not 100% clear what I am trying to do. I need help :(


How to use magento cache

Long story short:


$cache = Mage::app()->getCache();
$cache->save(date("r"), "nick_date", array("nicks_cache"), 10);



Zend_Cache takes care of the lifetime.


Cache the block that displays your news.
You can do that by adding these methods to the block class

protected function _construct()
        'cache_lifetime'=> 3600, // will be cached for an hour. you can adjust the value
        'cache_tags'    => array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG) //some cache tags...add others if needed

public function getCacheKeyInfo()
    return array(
    //add here any other key that might influence the display of your block

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.