How to configure Magento to use memcached
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.
- If you have a managed VPS or managed Flex Dedicated Server, please open a support ticket on the Customer Portal at https://my.a2hosting.com and request memcached for your system. We will install it for you.
- If you have an unmanaged VPS, Cloud VPS, or unmanaged Flex Dedicated Server, you can install memcached yourself.
- If you have a Turbo Web Hosting account, you should not follow the procedures in this article. Instead, use the A2 Optimized plugin to configure and manage memcached for your application.
- 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 need to 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:
'save' => 'db',
Modify this section as follows:
'save' => 'memcached',
'save_path' ==> '127.0.0.1:11211'
Save your changes to the env.php file. Memcached is now enabled.
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 </global> tag:
If these lines are not contained in the <global> section, Magento will not use memcached.
- Save your changes to the local.xml file. Memcached is now enabled.