Fast NVMe storage solves half the speed problem on a high-traffic WooCommerce store. The other half lives in the database layer — and that's where Redis object caching comes in.
This guide covers installing and configuring Redis as a persistent object cache on a bare-metal server running WordPress/WooCommerce, including the WooCommerce-specific gotchas that trip up most setups.
Why NVMe Alone Isn't Enough
Fast disks speed up reads and writes at the storage layer. But WordPress doesn't hit the disk for most page loads — it hits MySQL, repeatedly, for the same option rows, term hierarchies, user meta, and WooCommerce cart/session data. On a WooCommerce store, a single logged-in customer browsing a category page can trigger dozens of near-identical database queries per request.
Redis object caching sits between WordPress and MySQL, storing the results of those queries in memory. Instead of re-querying the database on every page load, WordPress reads the cached result from RAM in microseconds. The two layers are complementary:
- Page cache (Varnish, LiteSpeed Cache) caches fully rendered HTML for anonymous, logged-out visitors.
- Object cache (Redis) caches database query results for everyone, including logged-in users, cart pages, checkout, and the admin dashboard.
For WooCommerce specifically, this matters because cart, checkout, "my account," and admin order screens are never anonymous — they're exactly the pages page caching skips.
Hosting your stack on Bare Metal Servers allows you to dedicate sufficient RAM to Redis. By utilizing NVMe Dedicated Servers located in a secure London Data Centre, you ensure that the communication between PHP, Redis, and MySQL happens locally with near-zero latency.
Prerequisites
- A dedicated server running Ubuntu 22.04/24.04 or Debian 11/12.
- Root or sudo access.
- WordPress with WooCommerce already installed.
- PHP 8.1+ with the ability to install PHP extensions.
- At least 512MB–1GB of free RAM to dedicate to Redis.
Step 1: Install Redis Server
Update your package lists and install the Redis server:
bash
sudo apt update
sudo apt install redis-server -y
Check that it's running:
Bash
sudo systemctl status redis-server
redis-cli ping
A healthy install responds with PONG.
Step 2: Configure Redis Memory and Eviction Policy
By default, Redis has no memory limit and no eviction policy — which means it will happily consume all available RAM and then start refusing new writes once it's full. For a cache, that's the wrong behavior.
Edit /etc/redis/redis.conf and set the following values:
Plaintext
maxmemory 512mb
maxmemory-policy allkeys-lru
bind 127.0.0.1 -::1
maxmemory: Set this based on available RAM (WooCommerce typically needs 512MB–1GB).
maxmemory-policy allkeys-lru: Evicts the least-recently-used keys once memory fills. Never leave this on the default noeviction.
bind 127.0.0.1: Ensures Redis is bound to localhost only.
Restart to apply:
Bash
sudo systemctl restart redis-server
Step 3: Install the PHP Redis Extension
WordPress needs a PHP client to talk to Redis. The PhpRedis (PECL) extension is the fastest and most widely supported option:
Bash
sudo apt install php-redis -y
sudo systemctl restart php8.1-fpm # match your actual PHP-FPM version
Confirm it loaded:
Bash
php -m | grep redis
Step 4: Install the WordPress Object Cache Plugin
Install Redis Object Cache (by Till Krüss) from the WordPress plugin repository, or via WP-CLI:
Bash
wp plugin install redis-cache --activate
Step 5: Configure the Connection in wp-config.php
Add these constants above the /* That's all, stop editing! */ line in your wp-config.php file:
PHP
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_CACHE', true );
define( 'WP_REDIS_PREFIX', 'yourstore_' );
Note: If you're running multiple WordPress sites on the same server, set a unique WP_REDIS_PREFIX per site so their cache keys don't collide.
Step 6: Enable the Object Cache
Via WP-CLI:
Bash
wp redis enable
Or from Settings → Redis in the WordPress admin, click Enable Object Cache. Status should read Connected.
Step 7: WooCommerce-Specific Considerations
Cart and session behavior: WooCommerce stores cart contents primarily in a database session table and cookies, not through the object cache directly — so Redis won't break cart persistence.
REST API and checkout endpoints: WooCommerce's REST API and AJAX-driven checkout calls benefit noticeably from object caching, since these bypass page cache entirely and hit PHP/MySQL on every call.
Bulk imports: Bulk imports (product feeds, ERP syncs) can be faster with the object cache temporarily disabled, since writing thousands of cache entries during a one-time import adds overhead without ongoing benefit.
Step 8: Verify It's Actually Working
Enabling a plugin doesn't guarantee real performance gains — confirm cache hits are actually happening via the CLI:
Bash
redis-cli info stats | grep keyspace
Watch keyspace_hits climb relative to keyspace_misses as you browse the site. A healthy, warmed-up cache should show a hit ratio well above the miss ratio during normal browsing.
Top comments (0)