2

I never worked to cache Magento modules before. Now going to do for the first time so i have three questions regarding cache.

  1. What are the complete steps to cache a module?
  2. Any caching types are there?
  3. What are the pros & cons for this?

Can anyone help on this please.

1 Answer 1

2
  1. Not sure what you mean by caching a module. You don't cache a module, you cache a module's data - which can be anything from text, to json, html, objects, etc.

Usually, blocks & collection data should be cached, but you can cache anything else using Mage::app()->saveCache() and Mage::app()->loadCache(). Check the methods for the required parameters.

Blocks can be easily cached by extending Mage_Core_Block_Abstract and implementing the getCacheKeyInfo method - check the abstract class for more caching options.

Same for collections, see Mage_Core_Model_Mysql4_Collection_Abstract for more details - look for _canUseCache()

  1. Not sure what you mean by this. Magento uses various cache tags, but you're not bound to those, you can add any tag you like. Also, cache backends vary from files to memcached and redis, it's up to you which one you use.

  2. Pro's and con's for using caching? You should always cache operations that might take a long time to process, mostly those that are executed often and produce the same result. This is not really a magento question, it's more about application architecture, performance optimization and the desire to create a solid extension. try searching for "when should i cache data" on google.

Ultimately, look at the magento core code and see when they cache things and try to figure out why.

Your Answer

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

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