Configuring Magento to use memcached
Memcached is a high‑performance, distributed memory caching system that speeds up Magento by storing frequently accessed data in RAM. On ruachost.com, you can configure Magento to use Memcached for sessions and caching to improve page load times.
Why Use Memcached?
Section titled “Why Use Memcached?”- Reduces database load by caching queries and objects.
- Improves site speed and scalability.
- Ideal for busy Magento stores with high traffic.
Steps to Configure Magento with Memcached
Section titled “Steps to Configure Magento with Memcached”Step 1: Ensure Memcached is Available
Section titled “Step 1: Ensure Memcached is Available”- On Managed VPS/Dedicated Servers → Memcached can be installed by Ruachost support.
- On Unmanaged VPS → Install Memcached manually via SSH (
yum install memcachedorapt-get install memcached). - Memcached is not available on every shared hosting plan. Contact Ruachost support to confirm availability for your account.
Step 2: Configure Magento 2 to Use Memcached
Section titled “Step 2: Configure Magento 2 to Use Memcached”-
Log in via SSH.
-
Navigate to your Magento installation directory:
Terminal window cd ~/public_html -
Open the
app/etc/env.phpfile in a text editor. -
Locate the session configuration section:
'session' => ['save' => 'files',], -
Modify it to use Memcached:
'session' => ['save' => 'memcached','save_path' => '127.0.0.1:11211',], -
Save changes. ✅ Magento will now use Memcached for session storage.
Step 3: Configure Magento 1.9 and Older Versions
Section titled “Step 3: Configure Magento 1.9 and Older Versions”-
Log in via SSH.
-
Navigate to your Magento installation directory.
-
Open the
app/etc/local.xmlfile in a text editor. -
Add the following lines inside the
<global>section:<session_save><![CDATA[memcached]]></session_save><session_save_path><![CDATA[127.0.0.1:11211]]></session_save_path> -
Save changes. ✅ Magento will now use Memcached for session storage.
Important Notes
Section titled “Important Notes”- Always back up your site before editing configuration files.
- Replace
127.0.0.1:11211with the correct host and port if Memcached runs on a different server. - For advanced setups, you can configure Memcached for page caching as well.