Recently we were working on speeding up parts of client site which had usual problem of slow page loading caused by complicated configurable products. To solve the problem we were experimenting with extending core Magento caching capabilities.
Magento has built in predifined system of block output caching. Its block abstract has Zend_Cache caching capabilities that can be modified for your own needs. I’m showing here an example of caching whole product view block, however this is just a specific example of how things works, problems are different and requires different approach and solution.
I will start with some external reading and example itself. There is great article on Magento Wiki about this topic, along with category cache example on Magento forums.
With my Inchoo_BlockCaching.rar example module things should be little easier to understand.
Magento block caching depends of three things:
cache_lifetime => cache lifetime in seconds
cache_tags => cache type identifiers primarly used for deleting right cache at the right time
cache_key => cache identyfier
You can simply inject this data into construtor of any Magento block
or if you need some conditional approach like i did in this example define equivalent functions