Redis Object Caching:What It Does and When You Need It
Redis object caching keeps database query results in memory between requests. When it helps dynamic sites, when it makes no difference, and what your hosting must provide to use it.

Table of Contents
Redis object caching stores the results of database queries and other expensive operations in memory, so the next request can reuse them instead of asking the database again. It mainly speeds up pages that a full-page cache cannot serve: logged-in users, carts, checkouts, searches and admin screens.
If your site is mostly anonymous visitors reading cached pages, Redis may make little visible difference. If many visitors are logged in or shopping, it can reduce database load significantly.
What an object cache is
Applications like WordPress build each page from many small pieces of data: options, menus, post metadata, user data, product prices. Each piece normally comes from a database query. An object cache keeps those results in a fast key-value store, so a repeated request for the same data skips the database.
WordPress has a built-in object cache, but by default it is non-persistent: it lasts only for one page request and is thrown away afterwards. A persistent object cache, backed by Redis or Memcached, keeps the data across requests and visitors.
What Redis is
Redis is an open-source, in-memory data store. Because it keeps data in RAM, reads and writes are very fast. It is used for caching, sessions, queues and more. For website object caching, it sits next to the database:
- PHP needs a value and asks Redis first.
- On a hit, Redis returns it immediately.
- On a miss, PHP queries the database, uses the result, and stores a copy in Redis for next time.
When Redis helps
- WooCommerce and other shops, where carts and checkouts bypass the page cache.
- Membership, learning and community sites with many logged-in users.
- Busy admin areas, for example many editors working at once.
- Sites with expensive repeated queries, such as complex menus or option-heavy themes.
- Laravel and other frameworks, which can use Redis for cache, sessions and queues.
When it does not help much
- Small sites where almost every visit is served from the page cache.
- Sites whose slowness comes from large images, heavy JavaScript or slow external APIs.
- Servers with very little memory, where Redis would compete with PHP and MySQL for RAM.
Find the real bottleneck first with why is my website slow.
What your hosting must provide
- A Redis service you can connect to. On a VPS you can install it yourself. On shared hosting it is only available if the provider offers it per account, so check the plan details or ask support.
- The PHP Redis extension (
phpredis) or a compatible client library. - A connector in your application: for WordPress, an object-cache plugin that installs an
object-cache.phpdrop-in. - Enough memory, with a sensible maximum memory setting and eviction policy so Redis does not grow unchecked.
Isolate Redis on shared servers
Redis should never be reachable from the internet, and on servers with several sites each site needs its own instance, database or key prefix. Otherwise sites can read or overwrite each other's cached data.
Setting it up (overview)
On a VPS running WordPress:
- Install Redis and the PHP extension from your distribution's packages, and keep Redis bound to localhost or a Unix socket.
- Set
maxmemoryand an eviction policy such asallkeys-lruin the Redis configuration. - Install a Redis object-cache plugin in WordPress and enable the drop-in.
- Set a unique key prefix or database per site in
wp-config.php. - Check the plugin's status page for hits and misses, and measure response times for logged-in pages before and after.
Measuring whether Redis helps
Measure before and after enabling it, on the pages it is meant to help:
- Log in as a customer (or administrator) and note the response time of a few pages: the cart, checkout, account page and an admin screen.
- Enable the object cache and repeat the same requests several times (the first request after enabling fills the cache).
- Check the object-cache plugin's statistics: a healthy cache shows a high hit ratio.
- Use
redis-cli info statson a VPS to seekeyspace_hitsandkeyspace_misses, andredis-cli info memoryfor memory use.
If response times barely change, the bottleneck is elsewhere (slow external API calls, heavy plugins, or uncached queries that are not repeated).
Example configuration for WordPress on a VPS
Typical wp-config.php settings for a Redis object-cache plugin (exact constant names depend on the plugin):
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_PREFIX', 'shop_example_' );
And in the Redis configuration:
bind 127.0.0.1
maxmemory 256mb
maxmemory-policy allkeys-lru
The prefix keeps keys separate if several sites share one Redis instance; binding to localhost keeps Redis off the network.
Redis vs Memcached
Both are in-memory caches. Memcached is simpler and purely a cache. Redis supports more data types, optional persistence and features used for queues and sessions. For a typical website object cache either works; Redis is more common in current hosting setups.
Frequently Asked Questions
Do I need Redis if I already use a page cache?
They solve different problems. A page cache serves anonymous visitors; Redis helps the requests that page caching cannot serve. Many shops use both.
Can Redis break my site?
A misconfigured object cache can serve stale data or fill up memory. Most problems are fixed by flushing the cache and checking the key prefix and memory settings.
Is Redis the same as a database?
It can persist data, but for website object caching it is a temporary, disposable copy. The real data stays in MySQL or MariaDB.
Related reading
Redis is one of four caching layers described in website caching explained. For full control over software like Redis, see what is a VPS and the ServerNeed VPS plans. For hosting fundamentals, start with what is web hosting.
Sources
Last updated 7 October 2026



