Support for cache tags for all cache engines in the Magento enterprise version 1.13

Did you follow the Magento news, you probably heard that Magento Enterprise version 1.13 completely moved the indexer’s logic to the database server.

This for sure leads to a significant increase in your performance.

But are the indexers the only explanation for those better performances? No: there is a few other things involved in this upgrade: one of these is the support of the cache tags for all cache backends.

Memory cache backends usage is limited by the cache tags API

As a reminder, cache tags are flags you can set to each cached content. They allow to cluster cached data into groups.

Their main interest is to provide an API allowing to flush some cache content by their tag: this avoids to know each content identifier.

// clean all associated content related to block_html cache tag
Mage::app()->cleanCache(array('block_html'));

Their major problem is their native support: ome cache backends do not support them

Screenshot of a cache backend source code which does not support cache tags functionnality

the following cache tags does not support cache tags:

  • apc
  • memcached
  • libmemcached
  • xcache

Until this Magento EE 1.13 version, Magento bypassed this limitation by doing this: Cached data were stored into the memory backend (the fastest backend), but cache tag information were stored in another backend supporting this feature (the slowest backend).

How does the new cache tags policy work in the Magento Enterprise 1.13?

Now Magento emulates the cache tags support for faster backends: when Magento will save a content in cache, it will also save the list of related cache tags under a serialized string with a cache key based on a checksum of the string %cached_content_key%_tags: so we can manage all our cache tags policy into the fastest cache backend.

Saving a cache block content costs a cache backend additional hit, but avoids to hit the slowest backend.

The new Magento cache tags support for fast backends is only available for HTML content

We may regret that the support of this feature wasn’t made with some cache backend overloads, but on Mage_Core_Block_Abstract: so if you manage your cache policy only on cache block output, you’ll find benefits of this new feature, but if you manage your cache policy more deeper on models, you’ll continue to access the slowest backend.

The new cache tag management in Magento EE1.13, a must have

It’s somehow difficult to identify the performance gain only with this feature, because there are many other things added in this file (that I keep for a later discussion), and they should have a performance impact; but I’ve tested some partial upgrades of this version vs a EE1.11 and noticed until 25% fps more!

And if you work on a Magento Community edition, don’t be frustrated: Mage_Core_Block_Abstract is the same file in the Magento Community 1.8alpha version