What is Redis?

What-is-Redis-Blog-Banner

In this Article

We hear the term Redis quite a bit in the WordPress community these days, as it’s becoming more popular and supported. But what exactly is Redis? There are a lot of misconceptions about Redis, and often it can be a challenge to effectively implement it on your site. In this post, we’ll clarify some of these common misconceptions and also explain how to solve some of the more frequent issues that Redis users experience.

What is Redis?

Simply put, it’s an in-memory object cache. Let’s break this down, word by word. In memory means that it uses RAM, not disk memory, to store its data. This makes it extremely fast, which is one of the major benefits to using Redis. But how fast, you might wonder…

How Fast is Redis?

On an optimized WordPress site, it’s common to see PHP returning requests in the 100-400ms range and sometimes pure requests to the database take 300-500ms. So If you add those two together you would get your backend loading time of somewhere between 400-1000ms. But Redis, on the other hand, can process requests in tens of milliseconds. So a typical request in Redis is much faster than 100ms.

What is an Object Cache?

Okay, so if Redis is so fast, why doesn’t our entire website load in 50ms? This is where the Object Cache concept comes in. Remember Redis is an in-memory (RAM) object cache. We covered what in-memory is and we are all familiar with what Page Caching is, where the entire HTML page of your site is rendered, eliminating the need for PHP and a Database, making that specific page load very fast. But what about when a page cannot be cached, like the WordPress admin? This is where object caching comes into play.

You might be asking, what is an “object”? This is where object caching and Redis diverge from traditional caching. An object can really be anything, and it has to be specified by the developer writing the code to be able to take advantage of caching in Redis. Thankfully, WordPress has spent a lot of time building in support for Object Caching. Here are some examples of what can be turned into a cacheable Redis object. 

  • Database query results: Redis can store the results of frequently executed database queries. This helps to avoid querying the database repeatedly and improves response times.
  • Session data: User session information, such as user authentication tokens or session states, can be cached in Redis. This allows for quick retrieval and avoids the need to fetch the session data from a backend storage system for each request.
  • HTML fragments: Redis can cache pre-rendered HTML fragments or entire web pages. This can be useful in scenarios where the same content is served to multiple users, enabling faster response times and reducing server load.
  • API responses: If an application relies on external API calls to fetch data, Redis can cache the responses from these APIs. This helps to reduce the response time and mitigate the risk of hitting API rate limits.
  • Computed results: Redis data structures can store the results of computationally intensive operations. For example, if a particular calculation or transformation is performed frequently, the results can be cached in Redis to avoid redundant computations.
  • Configuration data: Static or rarely changing configuration data can be cached in Redis. This eliminates the need to read the configuration from a file or a database repeatedly, improving the application’s performance.
  • Frequently accessed data: Any data that is frequently accessed and benefits from faster retrieval can be cached in Redis. This could include frequently accessed user profiles, product catalog information, or any other data that experiences high read traffic.

All of the items above really help speed up WordPress when you are dealing with complex sites, like eCommerce ones,  where you users log in, APIs for shipping, and cart and checkout.

More comfortable with Redis now? Feel like you understand how a Redis cluster works? We hope so! While there is a lot of confusion surrounding what exactly you can do with Redis, it’s unquestionably a technology worth delving into.

About the Author

In this Article

Convesio Hosting Dashboard
Related Articles
Get WordPress Performance Tips
Subscribe to our monthly newsletter covering performance, innovation & running WordPress at scale.
[gravityform id="44" title="false"]