How to enable XCache in Magento

By default, Magento stores the cache on the file system. This is not optimized for performance as disk IO is usually a large bottleneck in any server, even with faster SSD disks. The speed can be greatly improved by using a fast backend cache in Magento. In this article we will explain how to configure Magento to use XCache as a fast backend. XCache is a fast, stable ​PHP opcode cacher and fast backend that has been proven and is now running on production servers under high load. XCache overcomes many of the problems found with other opcode caches such as being able to run with new ​PHP versions. There are other PHP caches available that do the same, such as the APC (Alternative PHP Cache).

To use XCache as a fast backend cache, simply add the following to your ./app/etc/local.xml:


Replace username_ with your actual username.

one caveat when using Xcache is that the implementation of Xcache backend provided by Magento is not fully compatible with the Zend 2-level caching. Therefore, when using Xcache you should edit the file ./app/code/core/Mage/Core/Model/Cache.php, and change the following section (line 181):

case 'xcache':
   if (extension_loaded('xcache')) {
      $enable2levels = false;
      $backendType = 'Xcache';

To prevent future upgrades to overwrite the changes, you should create a local copy/override of that file in ./app/code/local/Mage/Core/Model/Cache.php.

Was this answer helpful?