Magento 1.9 Cache – How to Check if Concrete Type of Cache is Enabled

cachemagento-1.9

For example how to check if "Blocks HTML output" is enabled, strangely I have trouble to find out that information.

I'd like to know that in order to add conditions before saving and loading custom cached content which is parts of the HTML block output and is programmed in the template file because in the inner HTML I had to output dynamic data a couple times, so I am doing custom "hole punching" and the block class is not caching the whole template.

Best Answer

Thats how you get all Cache types with the status

Mage::app()->getCacheInstance()->getTypes()

If you take a look in Mage_Core_Model_Cache you can see the Method canUse() The Description of the Method is:

Check if cache can be used for specific data type

I think it's exactly what you need and the return is true or false. You can call it like this:

Mage::app()->getCacheInstance()->canUse('block_html')