WordPress object cache with Redis on PHP 8

WordPress Redis object cache on PHP 8
Todays solution is: WordPress object cache with Redis on PHP 8.x.
I finally got sick of this old Hueman blog chewing MySQL for every menu, widget and post meta hit. Autoptimize already helps on the frontend. Nginx helper and page cache is another story. What actually moved the needle for admin clicks and repeat page builds was a proper object cache with Redis, not another “speed” plugin that rewrites half your HTML.
In this post i will show you how i wired Redis Object Cache on ispire.me while the site runs PHP-FPM 8.5. Same idea works on 8.1–8.4. CLI on the box can still be an older php, dont get confused by that.
Prerequisites:
- Debian/Ubuntu box with Redis server installed (
redis-server). - WordPress on Nginx + PHP-FPM 8.x (here: pool socket
/var/run/wordpress.sock). - Plugin Redis Object Cache by Till Krüss.
- PhpRedis extension for that PHP version (
php8.5-redisor whatever matches your FPM).
1. Install Redis and the PHP module
apt-get install redis-server php8.5-redis systemctl enable --now redis-server redis-cli ping # should answer PONG
If FPM and CLI differ (yes, that happens), install the redis module for the FPM version you actually use in Nginx, then restart the pool:
systemctl restart php8.5-fpm
2. Install the plugin and drop-in
Install “Redis Object Cache” from wp-admin or:
wp plugin install redis-cache --activate
Then enable the object cache drop-in (creates wp-content/object-cache.php):
wp redis enable
Or hit Enable in Settings → Redis. After that wp redis status should show Connected, Drop-in Valid, Ping 1.
On my box it looks roughly like this:
Status: Connected Client: PhpRedis Drop-in: Valid Redis Version: 7.0.x
3. What i did NOT bother with
- No Redis password on a localhost only listener. If Redis is on another host, lock it down.
- No fancy igbinary experiments on day one. Defaults first.
- I left page cache / Autoptimize as they were. Object cache is a different layer.
4. Did it actually help?
Short answer: yes for this site.
Before Redis, logged-in or semi-dynamic views kept hammering options and postmeta. After enabling the drop-in, Redis held a few hundred to ~1k keys under normal browsing and the MySQL “Sleep” pile calmed down. Hueman is chatty with widgets and sidebars. Object cache is exactly for that.
What did not magically fix TTFB alone: cold Nginx without FastCGI cache, fat homepage queries, and stupid amounts of plugins. Redis is not a replacement for fixing those.
If you already play with Memcached for PHP sessions (i wrote about that years ago: Store PHP Session via Memcached), keep sessions and object cache mentally separate. Different job.
5. Small ops notes
# flush object cache only wp redis flush # peek redis-cli INFO keyspace
After big plugin updates i flush once. Dont make a cron that flushes every 5 minutes, that defeats the point.
That should do it. Old Hueman blog, PHP 8.5 FPM, Redis 7, one drop-in. Boring setup, measurable calm on MySQL.