How to Setup Redis Cache on Magento Backend

by Fayyaz Khattak  June 8, 2017

Warning! This requires some technical changes in your Magento app. Therefore, we recommend that developers test this method on a staging website first.

If you need an exceptionally versatile data store shared by different procedures, numerous applications, or various servers, then deploying Redis cache on your Magento store is the best decision you will take.

Magento Redis

Magento supports many backend caches with the help of the Zend Framework. Memcache and APC are commonly used. However, nowadays Redis is fast becoming a popular and powerful caching system for use with Magento and other web applications. This is why it is important that developers should know how to configure Redis cache on Magento backend.

What is Redis Cache?

Redis cache lets you impart cross-stage, cross-server, or cross-application and makes it an excellent choice for numerous utilization cases. Its speed, likewise, makes it incredible as a cache layer.

Redis has a virtual memory, where once in a while utilized keys would be swapped out to circle so that only the keys needed to fit into the memory are used. Going ahead, the utilization cases for Redis are those where it’s feasible for the whole information set to fit into the memory.

The essential point of interest of utilizing Redis cache is that store labels are upheld. The moderate-level file system cache is no longer needed to be utilized. This Magento cache backend is prescribed in multi-server situations where you have more than one web server.

In this article, I am going to demonstrate how you can connect Redis with your Magento store using Cloudways Managed Magento Hosting Platform.

  1. Enable Redis Using Cloudways Platform
  2. Configure Redis With Magento
  3. Check if Redis is Working?

Enable Redis Using Cloudways Platform

  1. Sign in with your Cloudways account and click on your Server.

Select Server Cloudways

  1. Server Management console appears and click on Settings and Packages section.

server management console Cloudways

  1. In Setting and Packages, click on Packages tab.

navigate to packages Cloudways

  1. Now install the Redis as shown.

Install Redis Cloudways

5. Click on Manage Services.

Navigate to manage services Cloudways

6. In Manage Services, start the Redis.

Start the Redis Cloudways

Redis is now enabled on your Cloudways server.

Configure Redis With Magento

For the next step, you need to edit a couple of files. In Magento 1.9 there is a built-in Redis module, Cm_RedisSession.xml. To activate it, you need to access it through SFTP. You can find SFTP access details in Master Credentials.

SFTP access details Cloudways

Navigate to app/etc/modules/Cm_RedisSession.xml and open it in a text editor.

Change the value of <active> to true.

Save your changes to Cm_RedisSession.xml and exit the text editor.

Following code configures your Redis cache backend that you can use with your database index to hold a cache of your Magento store. Go to your local.xml file to tweak the code.

Here is the code that you need to copy and replace in your local.xml file. You can see your local.xml file under your magento root directory app/etc/local.xml.

Note: Use this code after <session_save><![CDATA[files]]></session_save>

Once edited, save your local.xml file. Then go to your var folder and delete all files and folders under the var/cache. Magento will rebuild the cache after a few hits on the website.

Check if Redis is Working?

Now check whether Redis Cache is working and connected with your Magento store or not. For this, Go to Server Management.

Launch SSH terminal Cloudways

In Server Management,click Launch SSH Terminal and use these two commands to check whether Redis Cache is working fine or not:

  • To check if Redis is working on the server, use this command redis-cli ping. (If you receive your PONG, you can proceed.)
  • In order to determine whether Redis configuration on your Magento store has been successful, use the redis-cli monitor command in the SSH Terminal. Each time your website is refreshed, you to view command line information of communication between your site and the Redis cache. To end the monitoring session, press Ctrl+C.

image01

  • For verifying PhpRedis, use this command php -m | grep redis. If you receive Redis. As a result, it’s mean your Redis cache is enabled and working fine with your Magento store.

PhpRedis

Final Thoughts

Enabling Redis on your Magento store will make it swifter. Users can deploy applications like Magento, WordPress, Laravel, Joomla, and PHP Stack in one-click on Cloudways. This is why it is essential that magento developers should know how to setup Redis cache in Magento backend.

The optimization formula of Cloudways uses Apache, Nginx and now, Redis. This unique combination significantly improves the performance of your web applications. Sign up now for a free trial of Cloudways Redis Cloud Platform.

Start Creating Web Apps on Managed Cloud Servers Now!

Easy Web App Deployment for Agencies, Developers and E-Commerce Industry

About Fayyaz Khattak

Fayyaz is a Magento Community Manager at Cloudways - A Managed Magento Hosting Platform. His objective is to learn & share about PHP & Magento Development in Community. Fayyaz is a food lover and enjoys driving. You can email him at m.fayyaz@cloudways.com

Stay Connected:

You Might Also Like...

  • Fernando

    Hi, i install and all work fine, but sessions files don’t is create in /var/session? same in /var/cache ? all permissions is ok and magento version is 1.9.2.3, Redis work whitout any files in folders?

    • proxium

      You need to add 1 after to make the backend cache working properly using Redis.
      I hope that they update this Blog post because the config file is not working (/var/cache/ folder is still used)

  • Wajid Hussain

    Hi elmi,
    I suggest you to use Redis cache for Sessions because Redis cache can handle sessions too.