Skip to main content
Performance

Redis Object Caching for WordPress: When You Need It

DDenis Makokha19 November 202617 min read14 views

Your homepage loads instantly, because a caching plugin serves a ready-made copy. But log in to your dashboard and every click drags. Your online store's cart takes seconds to update. A busy membership site slows down as soon as a few hundred people are logged in. You have installed a page caching plugin, compressed your images and updated PHP, and these pages are still slow.

The missing piece is often object caching, and the most popular way to do it is with Redis. Done well, it takes a huge amount of repeated work off your database. Done unnecessarily, it adds complexity and memory use for no benefit.

This guide explains what object caching is, how it differs from the other kinds of caching, which sites benefit and which do not, how to set up Redis for WordPress, how to keep it safe and how to test whether it helped.

Key takeaways

  • WordPress has a built-in object cache, but by default it only lasts for a single page request. A persistent object cache, such as Redis, keeps results in memory between requests.

  • Object caching reduces repeated database queries. It helps most on pages that page caching cannot serve: logged-in areas, carts and checkouts, dashboards, search and filtered lists.

  • It is not a replacement for page caching, and it is not a cure for slow code or a weak server.

  • Most brochure sites and blogs with good page caching and modest traffic do not need it.

  • Redis needs a server you can run it on, a PHP extension and a plugin or cache integration. On shared hosting, you depend on what the host provides.

  • Secure Redis properly. It must never be exposed to the internet without protection.

  • Measure before and after, using uncached and logged-in pages.

What Is Object Caching?

Every time WordPress builds a page, it asks the database a lot of questions: what are the site settings, which posts match this query, what does this menu contain, what are this user's permissions. Many of those questions are asked again and again, with the same answers.

An object cache stores the answers in fast memory so that WordPress can reuse them instead of asking the database each time. WordPress has had an internal object cache API for years. Out of the box, though, that cache is non-persistent: it exists only while a single page is being generated, then disappears. The next request starts from scratch.

A persistent object cache keeps the stored answers in an external memory store, such as Redis or Memcached, so that they survive between requests and are shared by every visitor. WordPress uses a special file called an object cache drop-in, placed in the wp-content folder, to talk to that store.

Object Cache vs Page Cache vs Other Caches

It helps to know the different layers, because they solve different problems.

Cache type

What it stores

Who benefits

Limits

Browser cache

Images, scripts and styles on the visitor's device

Repeat visitors

Only helps files, and only for that visitor

CDN cache

Static files, and sometimes pages, at locations near visitors

Visitors far from your server

Dynamic and personal pages usually bypass it

Page cache

Complete ready-made HTML pages

Anonymous visitors

Usually skipped for logged-in users, carts and checkouts

Opcode cache (OPcache)

Compiled PHP code

Every request

Speeds up PHP, not database queries

Object cache

Results of database queries and other computed data

Dynamic pages, including logged-in users

Needs a store such as Redis, and a plugin or integration

These layers work together. Page caching is usually the biggest win for anonymous visitors, and object caching speeds up the pages that page caching cannot help. Our guide to PHP versions and website speed covers the PHP side.

Why Redis?

Redis is an in-memory data store that holds keys and values and answers requests in a fraction of a millisecond. It is popular for WordPress object caching because it is fast, widely supported by hosts and plugins, can expire old data automatically and can handle a lot of simultaneous requests. Redis-compatible servers, such as Valkey, work the same way for this purpose.

Redis vs Memcached. Memcached is the other common choice. It is simple and fast for plain caching. Redis offers more features, such as richer data structures, optional persistence and more flexible tools, which is why many hosts and plugins favour it. For an ordinary WordPress cache, either works well, so use whichever your host supports best.

APCu is a third option that keeps the cache in the web server's own memory. It is fast and simple, but it is local to one server and is not shared across several servers.

Signs Your Site Might Need Redis Object Caching

Look for several of these together, not just one:

  • The admin dashboard is slow, especially when editing or searching in the post list.

  • Logged-in or uncached pages are slow, for example account pages, checkouts and member areas, even though public pages are fast.

  • Server response time (TTFB) is high on uncached requests, while cached pages are fine.

  • Your database is working hard. Resource graphs show high CPU or heavy I/O, or you see slow query warnings.

  • A page runs a large number of database queries. A profiling tool such as Query Monitor shows how many queries each page makes and how long they take.

  • You run WooCommerce, a membership site, a learning platform, a forum or another plugin-heavy site, where many requests cannot be page cached.

  • Lots of logged-in users at once, such as members, students or customers.

  • Resource limit faults appear in your cPanel resource usage, particularly CPU and entry processes. See our guide to reading your cPanel resource usage.

  • Traffic spikes make your site slow down even though page caching is on.

  • A large multisite network, where many sites share one database and code base.

When You Probably Do Not Need It

  • A small brochure site or blog that is almost entirely served from page cache.

  • Very low traffic, where the database is not under any strain.

  • Slowness caused by something else, such as huge images, a bloated theme, slow hosting or an outdated PHP version. Fix those first.

  • A host that already provides a persistent object cache, or a managed platform that handles it for you.

  • No one on the team to manage and monitor another service.

Object caching can also hide a problem, such as one terrible query or a badly written plugin. It helps, but cleaning up the root cause is better.

What Redis Needs From Your Hosting

Requirement

Notes

A Redis server

Provided by your host, or installed by you on a VPS or dedicated server

The PHP Redis extension

PhpRedis is the common choice. Some setups use a PHP library instead

A WordPress plugin or cache integration

Installs the object cache drop-in and connects WordPress to Redis

Enough memory

Redis keeps its data in RAM, so reserve memory for it and set a limit

A secure connection

Local socket or loopback address, with a password

Monitoring

You need to see memory use and the hit rate

On shared hosting, you normally cannot install your own services, so a persistent object cache is only possible if the host provides it. Check your plan, and ask SteboHost support what is available. On a VPS, where you have full root access, you can install and configure Redis yourself.

How to Set Up Redis Object Caching on a VPS

These steps assume an Ubuntu or Debian server and a WordPress site you control. Always take a backup first, and try it on a staging copy of your site before the live one. See our guide to staging environments.

Step 1: Install Redis

sudo apt update
sudo apt install redis-server

Check that it is running:

redis-cli ping

The answer should be PONG.

Step 2: Secure and size Redis

Open the Redis configuration file, usually /etc/redis/redis.conf, and review these settings:

bind 127.0.0.1 ::1
protected-mode yes
requirepass use-a-long-random-password
maxmemory 256mb
maxmemory-policy allkeys-lru

What they do:

  • bind makes Redis listen only on the local machine, not on the public internet.

  • protected-mode adds a safety net against accidental exposure.

  • requirepass sets a password. Choose a long random one, and keep it secret.

  • maxmemory caps how much RAM Redis may use for the cache. Choose a size that suits your server and your site, and leave room for everything else on it.

  • maxmemory-policy allkeys-lru tells Redis to remove the least recently used items when it is full, which is the usual choice for a cache.

Restart Redis after changing the file:

sudo systemctl restart redis-server

Never open the Redis port (6379) to the internet. Unprotected Redis servers are a well-known target for attackers.

Step 3: Install the PHP Redis extension

sudo apt install php-redis

The package name can include your PHP version, for example php8.3-redis, depending on how PHP is installed. Restart PHP or your web server afterwards, and confirm that the redis extension is loaded.

Step 4: Add the connection settings to WordPress

If you use the popular Redis Object Cache plugin, add these constants to wp-config.php, above the line that says "That's all, stop editing":

define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_PASSWORD', 'use-a-long-random-password' );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_PREFIX', 'mysite:' );

The prefix is important if more than one site shares the same Redis server, because it stops the sites from reading each other's cached data. Use a different prefix, or a different database number, for every site.

Step 5: Install and enable the plugin

In the WordPress dashboard, go to Plugins > Add New, install a reputable Redis object cache plugin, and activate it. Then go to its settings page and choose Enable Object Cache. This places the object cache drop-in in your wp-content folder. The status should change to Connected.

If you use WP-CLI, the same plugin offers commands such as:

wp redis status
wp redis enable

Some all-in-one cache plugins, including LiteSpeed Cache on LiteSpeed servers, include their own object cache setting that can connect to Redis or Memcached. Use only one object cache plugin, because WordPress allows just one object cache drop-in.

Step 6: Test, then watch

Browse your site as an anonymous visitor and as a logged-in user, update some content, test a checkout if you run a store and look in the dashboard for any errors. Then monitor memory use and the hit rate for a few days (see below).

Keep Redis Healthy

  • Check the hit rate. Redis reports how many lookups were found (hits) and missed. A healthy cache has a high proportion of hits. You can see the numbers with:

redis-cli info stats
redis-cli info memory

Look at keyspace_hits and keyspace_misses, and at used_memory compared with your maxmemory limit.

  • Watch memory and evictions. If Redis constantly evicts items because it is full, it may need more memory, or something is filling it with data that you do not need.

  • Flush after big changes. After a deployment, a migration or a large search-and-replace, clear the object cache, using the plugin's button or wp cache flush, so that stale data does not linger.

  • Keep Redis updated and monitor that it is running. Use a process manager such as systemd to restart it automatically.

  • Test failure behaviour. Most plugins fall back to the normal non-persistent cache if Redis is unavailable, but confirm how your setup behaves, so that a Redis outage does not take your site down.

  • Back up what matters. The cache itself is disposable, but your database and files are not. See backup and disaster recovery.

Security Considerations

A cache often holds database results, which can include personal and account data, so treat Redis as sensitive.

  • Bind Redis to the local machine, or use a Unix socket, and never expose it publicly.

  • Use a strong password, or access control lists, and keep secrets out of public repositories.

  • Use a firewall to block the Redis port from outside, and keep the server updated. See website security.

  • Use separate prefixes or databases for different sites, so that one site cannot read another's data.

  • If your site handles customers' personal data in Kenya, remember that it applies to cached copies as well. Our guide to the Data Protection Act explains the main duties.

WooCommerce and Membership Sites

Stores and membership sites are the classic case for object caching, because their key pages are personalised and cannot be fully page cached.

  • Cart, checkout and account pages run on every request, so repeated database lookups add up.

  • A persistent object cache reduces the cost of loading settings, products, user data and options on each of those requests.

  • Your plugin should treat user sessions and carts correctly, so check its documentation for stores.

  • Always test the full purchase path after enabling Redis, including coupons, shipping, taxes and payment returns.

  • Combine object caching with a clean database, optimised images and sensible plugin choices. See our guide to launching an online store in Kenya for the wider picture.

How to Measure Whether It Helped

Do not trust a feeling. Measure.

  1. Pick the pages that matter: the dashboard, a logged-in account page, the cart, the checkout and a filtered product or search page.

  2. Record the baseline before you enable Redis: server response time (TTFB), the number of database queries and total load time. A profiling plugin on a staging copy shows queries.

  3. Enable the object cache, and repeat the same tests several times, because the first visits fill the cache.

  4. Compare the numbers. Look for fewer database queries and a shorter server response time on uncached and logged-in pages.

  5. Watch your hosting graphs. CPU use, I/O and entry processes should be lower for the same traffic. See our guide to reading your cPanel resource usage.

  6. Run a load test on staging if you can, with a tool such as k6, to see how the site behaves with many users at once.

If nothing improves, the bottleneck is probably elsewhere, such as slow code, an external service, large images or an under-powered server, and Redis may not be worth keeping.

Common Problems and Fixes

  • The plugin says Redis is not connected. Check that the server is running, that the host, port and password match, that the PHP Redis extension is loaded and that nothing is blocking the connection.

  • Changes do not show up. Cached data is stale. Flush the object cache, and check that your plugins support object caching correctly.

  • Memory fills up. Raise the limit, make sure an eviction policy is set, and look for plugins that store huge amounts of data.

  • Two sites show each other's data. They share a Redis database with the same prefix. Give each site its own prefix or database number.

  • Errors about a drop-in. Another cache plugin installed its own object-cache.php. Remove one of them.

  • The site is slower. The connection may be slow or remote, or there is a configuration problem. Use a local connection, and check the settings.

  • The site breaks after an update. Flush the cache, and test the update on staging first.

Common Mistakes to Avoid

  • Installing Redis because "caching is good", without measuring a problem first

  • Expecting it to replace page caching

  • Leaving Redis open to the internet, or with no password

  • Letting several sites share one prefix

  • Running two object cache plugins at the same time

  • Giving Redis no memory limit, so it competes with the database and PHP

  • Forgetting to flush the cache after a deployment

  • Never checking the hit rate

  • Ignoring the real cause of slowness

A Quick Decision Guide

If this describes you

Then

Brochure site, page cache working, low traffic

You probably do not need Redis

Slow dashboard, uncached pages slow, plugin-heavy site

Redis object caching is worth testing

WooCommerce, membership or learning site with many logged-in users

Likely a strong candidate

Slow everywhere, with huge images or old PHP

Fix those first

Shared hosting with no Redis option

Ask your host, or consider a VPS if you need it

Busy site hitting resource limits after optimising

Combine Redis with a plan that has more headroom

Why Run a Performance-Sensitive Site on SteboHost

Object caching works best on a platform built for speed and with room to grow:

  • Fast foundations. LiteSpeed web servers and NVMe storage on SteboHost web hosting, with LiteSpeed caching on managed WordPress hosting. Ask SteboHost support whether a persistent object cache is available on your plan.

  • Full control when you need it. VPS and cloud hosting gives you dedicated CPU and RAM, full root access, Ubuntu, Debian and AlmaLinux images and snapshot backups, so you can run Redis yourself. See also Developer Hosting for developer-focused options.

  • Published resource limits on every plan page, so you can see where you stand. See the plan limits.

  • Monitoring that helps you measure. 24/7 infrastructure monitoring of uptime, resources and security events, and a public status page. See monitoring.

  • Security on every plan. A web application firewall, Imunify360 malware scanning and DDoS mitigation.

  • Daily backups on shared hosting plans, with 7-day retention and one-click restore, and staging on managed WordPress for safe testing.

  • Migration help on annual plans. Terms are shown on the pricing page and at checkout.

  • Local support on +254 703 610 464 during East Africa Time business hours, with 24/7 urgent monitoring, and billing in KES by M-Pesa, card or bank transfer.

Current plan and renewal prices are shown on the pricing page before you buy. You can also browse the knowledge base for more performance guides.

Conclusion

Redis object caching is a powerful tool for the right problem: dynamic, logged-in, database-heavy pages that page caching cannot reach. It is not a magic switch, and it adds a service you must secure and watch. Start by measuring where your site is slow, fix the basics, and add Redis if the data points to repeated database work. Then test, monitor the hit rate and keep it protected.

Not sure whether your site needs it, or whether your plan supports it? Contact the team or call +254 703 610 464, and SteboHost will help you work out the right setup.

Frequently Asked Questions

What is Redis object caching in WordPress?

It is a way of storing the results of database queries and other repeated operations in fast memory, using Redis, so that WordPress can reuse them across page requests instead of asking the database each time. It needs a Redis server, a PHP extension and a plugin or cache integration.

Is object caching the same as page caching?

No. Page caching stores complete finished pages for anonymous visitors. Object caching stores smaller pieces of data, such as query results, and helps pages that cannot be fully cached, such as dashboards, carts and logged-in areas. Most busy sites use both.

Does my WordPress site need Redis?

Only if the evidence suggests so. Slow dashboards, slow logged-in or uncached pages, heavy database use and plugin-heavy sites such as stores and membership sites are good signs. A small brochure site with working page caching and modest traffic usually does not need it.

Is Redis better than Memcached?

Both work well for WordPress object caching. Redis has more features and is widely supported by hosts and plugins, while Memcached is simple and fast. Use whichever your host supports best, and make sure it is configured and secured properly.

Can I use Redis on shared hosting?

Only if your host provides it, because you usually cannot install your own services on shared hosting. Ask your host what persistent object cache options are available on your plan. If you need your own Redis server, a VPS with root access lets you install and manage it.

Is it safe to use Redis?

Yes, if it is set up securely. Bind it to the local machine or a socket, require a password, block the port in your firewall and keep it updated. Never expose a Redis server to the internet without protection, because exposed servers are a known target.

How do I know whether Redis is working?

The plugin's status page should show Connected, and the Redis statistics should show lots of cache hits. To prove it helps, compare database queries, server response time and resource use on logged-in and uncached pages before and after enabling it.

#Redis#Object Caching#WordPress#Performance#WooCommerce#Caching#Database#VPS
D

Written by Denis Makokha

SteboHost engineering and operations team. We write practical guides on hosting, domains, email and security for African businesses — based on what we see in the field, not marketing copy.

Ready to get started?

Browse our hosting plans or contact our team for help choosing the right one.