Magento - configuring memcached

Magento - configuring memcached

September 5, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - configuring memcached

Configuring Memcached for Magento: A Comprehensive Guide

When it comes to enhancing your Magento store’s performance, leveraging caching mechanisms like memcached can significantly improve its speed and responsiveness. In this guide, we’ll walk you through the process of configuring memcached in Magento step-by-step.

Understanding Magento’s Caching System

Before diving into the configuration, let’s briefly understand Magento’s caching system. By default, Magento uses file-based caching for slow data (like layouts) and memcached for fast data (like compiled templates). The local.xml file is where you’ll define your cache backends.

Configuring Memcached in local.xml

To configure memcached, open your local.xml file located in the app/etc directory of your Magento installation. You may find existing cache configurations there. Here’s an example of how to add memcached configuration:

<cache>
  <slow_backend>File</slow_backend>
  <fast_backend>memcached</fast_backend>
  <fast_backend_options>
    <servers>
      <server>
        <host>localhost</host>
        <port>11211</port>
        <persistent>1</persistent>
      </server>
    </servers>
  </fast_backend_options>

  <backend>memcached</backend>
  <memcached>
    <servers>
      <server>
        <host>localhost</host>
        <port>11211</port>
        <persistent>1</persistent>
      </server>
    </servers>
  </memcached>
</cache>

In this configuration:

  • slow_backend defines the backend for slow data (File in this case).
  • fast_backend defines the backend for fast data (memcached here).
  • The <servers> tag specifies where your memcached server is running. In this example, it’s on localhost:11211.

Verifying Memcached Configuration

After adding this configuration to your local.xml file, save it and open a terminal/command prompt. Run the following commands:

telnet localhost 11211

Then, refresh your Magento store pages in the browser. If memcached is successfully configured, you should see output similar to this:

<29 new auto-negotiating client connection
29: Client using the ascii protocol
<29 stats
<30 new auto-negotiating client connection
30: Client using the ascii protocol
<30 stats
<31 new auto-negotiating client connection
31: Client using the ascii protocol
<31 get 28e_CORE_CACHE_OPTIONS
>31 END
<31 stats
<31 delete 28e_TRANSLATE_EN_GB_FRONTEND_1_DEFAULT_XXXXX
>31 NOT_FOUND

The <29, <30, and <31 represent new client connections. The get and delete commands indicate that Magento is communicating with memcached.

Best Practices for Memcached Configuration

  1. Install the Required PHP Extension: Ensure you have the memcache or memcached extension installed in your PHP configuration to interact with the cache server.
  2. Monitor Cache Usage: Regularly check your memcached statistics (stats) to ensure it’s not filling up and causing evictions.
  3. Optimize Memory Allocation: Adjust your Magento configuration to allocate memory efficiently for both file-based and memcached backends.

Conclusion

Configuring memcached in Magento is a straightforward process that can significantly boost your store’s performance. By following the steps outlined above, you’ll be able to harness the power of this distributed caching system effectively.

Remember, proper monitoring and optimization are key to ensuring memcached operates at its peak efficiency for your specific Magento setup. If you’re looking for more advanced performance tuning tips, check out our in-depth guide on Magento Performance Optimization on the LaravelCompany blog.

Happy caching!

Cache Performance Themes Admin

Our network