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 configuring Magento, Redis cache is the best decision you will take.
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.
Scale Your Magento 2 Store With Ease
One-Click Magento installation with your own managed hosting solution.
In this article, I am going to demonstrate how you can connect Magento, Redis cache using Cloudways Managed Magento Hosting Platform.
Enable Redis Using Cloudways Platform
- Sign in with your Cloudways account and click on your Server.
- Server Management console appears and click on Settings and Packages section.
- In Setting and Packages, click on Packages tab.
- Now install the Redis as shown.
5. Click on Manage Services.
6. In Manage Services, start the Redis.
Redis is now enabled on your Cloudways server.
Configure Redis With Magento
In the next step of configuring Magento, Redis cache, 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.
Navigate to app/etc/modules/Cm_RedisSession.xml and open it in a text editor.
Change the value of <active> to true.
<config> <modules> <Cm_RedisSession> <active>true</active> <codePool>community</codePool> </Cm_RedisSession> </modules> </config>
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.
<cache> <backend>Cm_Cache_Backend_Redis</backend> <backend_options> <server>127.0.0.1</server> <port>6379</port> <persistent></persistent> <password></password> <force_standalone>0</force_standalone> <connect_retries>1</connect_retries> <read_timeout>10</read_timeout> <automatic_cleaning_factor>0</automatic_cleaning_factor> <compress_data>1</compress_data> <compress_tags>1</compress_tags> <compress_threshold>20480</compress_threshold> <compression_lib>gzip</compression_lib> <use_lua>0</use_lua> </backend_options> </cache>
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.
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.
- 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.
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.
Boost Your Magento Store Performance by 5x Times & Maximize Your Sales
Our fastest Magento hosting can help you in growing your business revenue by 500%
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 firstname.lastname@example.org