How To Use Redis Object Cache To Speed Up Dynamic WordPress Site

With RunCloud, you don’t need to be a Linux expert to host high-performance WordPress websites, both “static” WordPress sites (simple blog) and “dynamic” WordPress sites (WooCommerce and membership).

For any types of highly dynamic websites, you can use Redis Object Cache to use less database resources by caching the results of complex database queries, speed up PHP execution time in your server, and make your dynamic website load much faster.

In this blog post, we will explain Redis Object Cache, which is probably not a term that many WordPress users are familiar with.

WordPress Caching System

WordPress users usually understand at least two caching systems: page caching and browser caching.

Actually, there are many caching system in WordPress, for example:

  • page caching
  • browser caching
  • database caching
  • object caching
  • transient caching
  • fragment caching
  • opcode caching
  • CDN caching

In RunCloud, we divide them into three types:

  1. Server-side Caching: caching at the server level. NGINX page caching (RunCloud Hub) and Varnish page caching are two examples of server-side caching.
    • They are not available on regular shared hosting.
    • You will need a VPS / Dedicated server to allow you to optimize your website using server-side caching.
    • Another example of server-side caching is “persistent” object caching.
  2. WordPress-side Caching: caching at the WordPress level. Page caching feature of many popular caching WordPress plugins is one example of WordPress-side caching.
    • You can control it from your WordPress dashboard.
  3. Client-side Caching: caching at the local browser level. Browser cache is an example of client-side caching.
    • Once you visit your website, your browser saves the static data of your website, such as images, CSS, and javascript files.
    • Everytime you visit your website again or hit the F5 button to refresh your website, static data will be served from the local browser cache.

For this post, we will only be covering the object cache, specifically Redis Object Cache.

What is Redis Object Cache

If page caching works on caching the HTML page output, then object caching works on caching your database queries.

WordPress has special WP_Object_Cache class for caching the result of complex database queries, which may be computationally expensive to regenerate, to reduce your server load.

By default, the object caching is non-persistent, data stored in the cache resides in memory only and only for the duration of the request.

We can make it persistent, cached data can be used across page loads, by using persistent object caching system, for example:

  • Redis Object Cache
  • Memchached Object Cache
  • APC / APCu Object Cache
  • File-based Object Cache

Redis Object Cache is the first choice because it is very popular and used by many popular websites like Twitter, GitHub, Weibo, Pinterest, Snapchat, Craigslist, Digg, StackOverflow, Flickr, and many others.

When a user visits a WordPress page, many complex database queries are performed on your server and the results are cached by Redis Object Cache.

When another user visits the same WordPress page, your website will not perform the same complex database queries again, because the results are already cached and served by the Redis Object Cache.

It will reduce your database queries, reduce your server load, and make your dynamic WordPress site load faster.

Who Need Redis Object Cache

Page caching is enough for many WordPress sites, especially for blogs, magazines, news, and company profile websites.

But if your WordPress site has many dynamic pages, page caching will be not enough because your dynamic pages should be not cached using page caching.

For example, Redis Object Cache will be very useful for these dynamic websites to reduce your MySQL database load and make your dynamic pages load faster.

  • E-commerce websites using WooCommerce, Easy Digital Downloads, etc. Your cart, checkout, and my account pages are dynamic pages.
  • Membership websites. Your member area and some password protected pages are dynamic pages.
  • Forums and Social Networking websites using BBPress, BuddyPress, etc.

How To Use Redis Object Cache

Redis Object Cache is a server-side caching, and it requires Redis to be installed and activated in your server.

For RunCloud users, there is no need to install Redis yourself, as Redis has been installed to your server.

It saves your time dealing with the linux command to install Redis. It can be complicated for common users with minimum linux knowledge.

In RunCloud, there are two ways to use Redis Object Cache.

  1. RunCloud Hub WordPress Plugin
  2. Redis Object Cache WordPress Plugin

How To Install Redis Object Cache Using RunCloud Hub

RunCloud Hub is a hub for all RunCloud plugins for WordPress. It is not only for Redis Object Cache, but also RunCache (Nginx server-side caching) and Server Health & Transfer Stats monitoring directly from your WordPress dashboard.

If you want to use a combination of Nginx page caching and Redis object caching, then RunCloud Hub is the perfect choice for you.

You can read the complete guide on how to install RunCloud hub here.

Once you have installed the RunCloud Hub plugin, Redis Object Cache is automatically installed and enabled in your WordPress website, no complex process required.

runcloud-redis-object-cache-runcloud-hub

You can also disable Redis Object Cache temporarily by unchecking “Handle Object Cache” option under Redis settings in RunCloud Hub page.

How To Install Redis Object Cache Using Redis Object Cache WordPress Plugin

If you do not want to use RunCache (Nginx page caching) in RunCloud Hub, and only want to use Redis Object Cache, you can use Redis Object Cache WordPress Plugin.

First, you need to run Redis on your RunCloud server. Redis has been installed in your server, but it is probably inactive. Go to Services menu under your server in RunCloud, and enable Redis.

Second, install and activate Redis Object Cache WordPress Plugin.

Third, enable the object cache under Settings – Redis, or in Multisite setups under Network Admin – Settings – Redis.

runcloud-redis-object-cache-wordpress-plugin

Note: If you use Redis Object Cache in multiple websites (web applications) in single RunCloud servers, you have to add WP_CACHE_KEY_SALT constant to wp-config.php of each web applications. Please read plugin documentation for more details.

How To Check If Redis Object Cache Works

Redis Object Cache works by reducing your complex database queries. We can monitor and compare the database queries before and after using Redis Object Caches.

You can install and activate Query Monitor WordPress plugin to help you monitor the number of database queries in a WordPress website.

In this example, we use a default WordPress installation with Twenty Nineteen WordPress theme.

runcloud-redis-object-cache-dashboard-before
Redis Object Cache in WordPress Dashboard page (BEFORE)
runcloud-redis-object-cache-dashboard-after
Redis Object Cache in WordPress Dashboard page (AFTER)

In WordPress dashboard, Redis Object Cache can reduce the number of database queries from 25 to 10 queries only.

runcloud-redis-object-cache-frontend-before
Redis Object Cache in WordPress Homepage (BEFORE)
runcloud-redis-object-cache-frontend-after
Redis Object Cache in WordPress Homepage (AFTER)

In WordPress homepage, Redis Object Cache can reduce the number of database queries from 18 to 5 queries only.

You can imagine when you use Redis Object Cache in a WooCommerce (ecommerce) website, where the number of database queries in your WordPress can be 50-100 queries per page, Redis Object Cache can help a lot!

Summary

Redis Object Cache is a very useful feature to speed up dynamic WordPress sites, especially ecommerce (WooCommerce) and membership sites by reducing database load to make your dynamic pages load faster.

All paid plan users (Basic, Pro, Business) can enjoy the full functionality of this feature.

Never ever hesitate to suggest new features that you want to see, and we will make it happen.

Categories: WordPress, Features, Tutorials

Simplifying Server Management

RunCloud is a cloud server management tool that allows you to maintain full control of your server and host multiple WordPress, WooCommerce, Laravel, and PHP applications with fast and easy configuration.

Start Your Free Trial

5 days free trial no credit card required cancel anytime

4 thoughts on “How To Use Redis Object Cache To Speed Up Dynamic WordPress Site

  1. Hello RunCloud blog readers,

    We hope you can enjoy this Redis Object Cache blog post.

    We will have a lot of blog posts to cover all RunCloud awesome features and best practices for you.

    Let us know if you have any idea of blog post that we should write for you. 😉

Leave a Comment

Your email address will not be published. Required fields are marked *