Configuring Magento to use memcached
Boost the performance of your Magento site with memcached! Follow our easy step-by-step instructions to add this powerful caching solution on your Magento site!
This article describes how to configure Magento to use memcached.
Memcached is an open-source memory object caching system that web sites can use to help accelerate page load times. Memcached works by caching in RAM frequently accessed data, such as the results of API calls, database calls, and more.
Note
If you have a managed VPS or managed Dedicated Server, please open a support ticket on the Hosting Panel at https://my.hosting.com and request memcached for your system. We will install it for you.
If you have an unmanaged VPS, you can install memcached yourself.
Memcached is not supported on non-Turbo shared hosting accounts at this time.
Enabling memcached for Magento 2
To enable memcached for Magento 2, you must change some settings in the env.php file. To do this, follow these steps:
-
Using your preferred text editor, navigate to the directory where you installed Magento, and then open the app/etc/env.php file.
-
Locate the following section in the env.php file:
'session' => [
'save' => 'files'
],
- Modify this section as follows:
'session' => [
array (
'save' => 'memcached',
'save_path' => '127.0.0.1:11211'
),
],
- Save your changes to the env.php file. Memcached is now enabled.
Tip
For additional information about how to configure memcached with Magento 2, please visit http://devdocs.magento.com/guides/v2.0/config-guide/memcache/memcache_magento.html.
Enabling memcached for Magento 1.9 and older versions
To enable memcached for Magento 1.9 and older versions, you need to add some settings to the local.xml file. To do this, follow these steps:
-
Using your preferred text editor, navigate to the directory where you installed Magento, and then open the app/etc/local.xml file.
-
Add the following lines just before the closing tag:
<cache>
<backend>memcached</backend>
<memcached>
<servers>
<server>
<host><![CDATA[127.0.0.1]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
</server>
</servers>
<compression><![CDATA[0]]></compression>
<cache_dir><![CDATA[]]></cache_dir>
<hashed_directory_level><![CDATA[]]></hashed_directory_level>
<hashed_directory_umask><![CDATA[]]></hashed_directory_umask>
<file_name_prefix><![CDATA[]]></file_name_prefix>
</memcached>
</cache>
Important
If these lines are not contained in the section, Magento will not use memcached.
- Save your changes to the local.xml file. Memcached is now enabled.
More Information
-
For more information about memcached, please visit http://www.memcached.org.
-
To view the official Magento documentation, please visit http://www.magentocommerce.com/knowledge-base.
Updated 22 days ago