Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,156,786 members, 7,831,544 topics. Date: Friday, 17 May 2024 at 08:35 PM

How To Optimize Wordpress Performance With Redis Caching - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / How To Optimize Wordpress Performance With Redis Caching (313 Views)

How To Leverage Browser Caching Of Your Website To Improve Page Load Speed / Leverage Browser Caching Is Affecting Your Wordpress Website/blog - Solution / How To Optimize Blog Post Title For Better SEO Ranking (A Detailed Guide) (2) (3) (4)

(1) (Reply)

How To Optimize Wordpress Performance With Redis Caching by todhost(m): 6:03pm On Jun 15, 2020
Redis and object caching will exponentially speed up your WordPress page load time with every subsequent visit.

In this guide, we will cover how to configure Redis as a cache for WordPress to lessen all redundant and time-consuming database queries that are used for rendering a WordPress page. The result of this will be a WordPress site that is exceptionally faster, uses much fewer database resources, in addition to providing a tunable and persistent cache. Keep in mind that the guide applies to CentOS 6 and cPanel.

What is covered in this post:

How Does Caching Work?
What Exactly is Redis?
Benefits of Redis
Installing Redis, PHP-Redis, and WordPress
Prerequisites
Install Redis
Configure Redis
Install PHP-REDIS
Configure WordPress Caching
Restart Redis and Apache via SSH
Verify the Setup

How Does Caching Work?

Whenever a web page is cached, the elements of that particular page such as images, stylesheets, and other content, are loaded once, and then stored in what we call a “cache.” The cache memorizes everything that was loaded, creates a static version of it, and then can serve that version much faster the next time the page loads. The result is a much faster page load time and fewer server resources being used.

Every time we access a WordPress page, a query is being executed to the WordPress database to fetch the page’s content. By using Redis caching, the results of this query are stored into the Redis-managed block. Upon additional requests of the same page, the data will be retrieved from the Redis cache, eliminating the need for execution of the MySQL query, which could be essential even if we have only a few visitors on our WordPress site. Retrieving the data via Redis directly from the memory can make our page load speed blazing fast.

The solution above is most beneficial for WordPress sites with a large number of simultaneous requests as reducing the number of concurrent queries dramatically improves the performance, provides better utilization to the server and eliminates the MySQL bottleneck. This way, the site can handle more traffic without the need for more powerful hardware.

Also, caching with Redis eliminates any need for flushing the cache whenever we publish new content manually. In case we edit a page, or we post new content to our WordPress site, the Redis cache for the posted content would be invalidated to avoid “dirty” cache. The content will be updated after the next page load.

What Exactly is Redis?

Redis is an open source advanced key-value cache store. It can operate as both cache and an in-memory store. Usually, Redis is referred to as a data structure server, and it’s known for having outstanding performance as it works with an in-memory dataset. Although similar results can be witnessed with some other cache softwares like Memcached, Redis is one of the best choices. It’s not too hard to set up and use. Additionally, we are going to cover how to set up Redis on CentOS 6 server with cPanel, how to set up php-redis, as well as perform the needed configuration settings on our WordPress installation and boost its performance exponentially.
Benefits of Redis

Websites that are highly dynamic and cannot make good use of page caching are a good target for the persistent object caching* option that is Redis. Generally, Redis would not help the load time of static blogs, news websites, and informational business websites, unless those sites use page caching poorly. However, Redis offers a great deal of support for developing efficient caching mechanisms. It takes just a couple of minutes to implement a cache mechanism and get it working with the chosen application. The outcome we get is a high-performing cache system. With it, you can have huge keys and values of objects.

*Object caching - involves storing database queries. When enabled on a WordPress site, it helps in speeding up PHP execution times, reduces the load on the database, in addition to delivering content to the site's visitors faster.

WordPress also has object caching built-in with the WP_Object_Cache class.

While on a WordPress context, we can use Redis to store the values generated by the native object cache of WordPress. We can do that in a persistent manner so that all cached objects would be reused between page loads.

(1) (Reply)

I Will Design Catchy And Beautiful Flyer Design For Just 1k (pictures) / These Are The 5 Websites I Thought You Have Never Seen Before / Make Money And Have A Financial Breakthrough Trading Fx(forex)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.