Configuring Redis Object & Server Caching on Managed WordPress
Learn how to set up Redis object caching and server-level Nginx FastCGI page caching to dramatically speed up your WordPress website today.
7 min read
Running a WordPress site on a managed server gives you a solid foundation, but to keep page loads snappy, you still need additional caching layers. Two of the most effective techniques are Redis object caching, which keeps database query results in memory, and server-level caching, which serves static HTML before WordPress even runs. This guide walks you through the entire process: installing Redis, wiring it up with a WordPress plugin, and adding a fast page-cache layer. The steps are written for both Debian/Ubuntu (APT) and AlmaLinux/Rocky/RHEL (DNF) environments, so you can follow whichever stack your managed WordPress hosting uses.
1. Why Combine Redis and Server-Level Caching?
WordPress handles three main tasks on every request:
PHP execution – runs the theme and plugins.
Database queries – fetches posts, options, and metadata.
HTML delivery – sends the final page to the visitor.
Each step adds latency. Redis reduces database time by keeping frequently accessed rows in RAM. A server-level cache (FastCGI cache, Nginx proxy_cache, or Apache mod_cache) stores the fully rendered HTML, so PHP never runs for cached pages. Together, they keep dynamic content fast and static pages instant.
2. Installing Redis on Your Managed Server
First, verify that the Redis daemon is available on the host. If your platform already offers a Redis service, skip the installation and note the host/port provided.
Debian / Ubuntu (APT)
# Update package index
sudo apt update
# Install Redis server and CLI tools
sudo apt install -y redis-server
# Enable and start the service
sudo systemctl enable --now redis-server
# Verify it is listening on 127.0.0.1:6379
sudo netstat -tlnp | grep redis
Command explanations:
apt update refreshes the local package list.
apt install -y redis-server installs Redis and its client utilities.
systemctl enable --now configures Redis to start at boot and launches it immediately.
netstat confirms the daemon is listening on the default port.
AlmaLinux / Rocky Linux / RHEL (DNF)
# Enable the EPEL repository (provides Redis for RHEL-based systems)
sudo dnf install -y epel-release
# Install Redis and its tools
sudo dnf install -y redis
# Start and enable the service
sudo systemctl enable --now redis
# Check the listening socket
sudo ss -tlnp | grep redis
The steps are similar to the APT block but use DNF and the epel-release repository, which is required for Redis on RHEL-based platforms.
3. Securing Redis for WordPress
By default, Redis accepts connections only from 127.0.0.1, which is suitable for a typical managed WordPress server. You can tighten security further by adding a password.
Set a password (both distros)
# Open the Redis configuration file
sudo nano /etc/redis/redis.conf # Debian/Ubuntu
# or
sudo nano /etc/redis.conf # AlmaLinux/Rocky/RHEL
# Find the line that starts with # requirepass and uncomment it:
requirepass yourStrongPassword123
# Save and exit, then restart Redis
sudo systemctl restart redis
Replace yourStrongPassword123 with a strong secret. WordPress will need this password later.
4. Connecting WordPress to Redis (Object Cache)
WordPress does not ship with a built-in Redis object cache, so you’ll install a plugin that registers Redis as the object cache backend.
Step-by-step
Log in to your WordPress admin dashboard.
Navigate to Plugins → Add New.
Search for Redis Object Cache (by Till Krüss).
Install and activate the plugin.
Open wp-config.php (via SFTP/SSH or the file manager) and add the following lines before the “/* That's all, stop editing! */” comment:
/** Enable Redis object caching */
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_PASSWORD', 'yourStrongPassword123' ); // omit if you left password blank
define( 'WP_REDIS_DATABASE', 0 );
These constants tell the plugin where to find Redis and which database to use.
Verify the connection
After saving wp-config.php, go back to the WordPress admin panel. The Redis plugin adds a status page under Tools → Redis. You should see “Status: Connected”. If not, double-check the host, port, and password.
5. Adding Server-Level Page Caching
Object caching speeds up database calls, but the fastest wins are full-page caches that serve static HTML. Most managed WordPress hosts run Nginx with FastCGI caching; the same concepts apply to Apache with mod_cache. Below are the Nginx steps; adapt as needed for Apache.
Configure FastCGI cache (Debian/Ubuntu)
# Create a directory for cached files
sudo mkdir -p /var/cache/nginx/fastcgi
# Set proper permissions (www-data is the typical web user)
sudo chown -R www-data:www-data /var/cache/nginx/fastcgi
# Edit the Nginx site config (example: /etc/nginx/sites-available/example.com)
sudo nano /etc/nginx/sites-available/example.com
Insert the following block inside the server context, preferably after the location / block:
# FastCGI cache settings
fastcgi_cache_path /var/cache/nginx/fastcgi levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key $scheme$request_method$host$request_uri;
# Cache only successful HTML responses
set $skip_cache 0;
if ($request_method != GET) {
set $skip_cache 1;
}
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
if ($skip_cache = 0) {
add_header X-Cache-Status $upstream_cache_status;
}
Then modify the existing PHP handling block (usually location ~ \.php$) to use the cache:
The same fastcgi_cache_path and location blocks from the Ubuntu example apply; just ensure the PHP socket points to the correct version, e.g., /run/php-fpm/www.sock or 127.0.0.1:9000. After editing, run:
sudo nginx -t
sudo systemctl restart nginx
What the directives do
fastcgi_cache_path creates a disk-based cache zone named WORDPRESS with a 100 MB key store.
fastcgi_cache_key builds a unique key per URL, scheme, and request method.
The if blocks set $skip_cache for non-GET requests or when cookies that indicate logged-in users are present, preventing caching of personalized pages.
fastcgi_cache_valid tells Nginx to keep 200/301/302 responses for 60 minutes.
add_header X-Cache-Status adds a debug header so you can see HIT, MISS, or BYPASS in the response.
6. Testing, Monitoring, and Troubleshooting
With both layers active, verify they work as expected.
Check Redis object cache
# Connect to Redis CLI
redis-cli -a yourStrongPassword123 INFO stats
# Look for key statistics, e.g., "keyspace_hits" and "keyspace_misses"
Higher hit counts indicate the object cache is being used.
Validate FastCGI cache
Use curl to request a page and inspect the custom header:
You should see X-Cache-Status: MISS on the first request and HIT on subsequent ones (provided the page is cacheable).
Common issues
Redis connection refused – Ensure the Redis service is running and the password matches the one in wp-config.php.
Cache never hits – Check the $skip_cache conditions; stray cookies or a misconfigured fastcgi_cache_bypass can force bypass.
Stale content – Purge the FastCGI cache when you publish new posts. You can do this manually:
# Delete cache files for a specific URL
sudo rm -rf /var/cache/nginx/fastcgi/*your-post-slug*
Or use a plugin that provides a “Purge Cache” button linked to Nginx.
7. Putting It All Together – Best-Practice Checklist
Redis installed, secured with a password, and running.
WordPress wp-config.php contains the Redis connection constants.
Redis Object Cache plugin is active and shows “Connected”.
Nginx FastCGI cache directory exists, owned by the web user, and is referenced in the site config.
Cache-bypass rules respect logged-in users and POST requests.
Headers like X-Cache-Status are visible for quick verification.
Following this checklist ensures both the database layer and the page-delivery layer are optimized without interfering with each other.
Conclusion
Adding Redis object caching and a server-level FastCGI cache transforms a standard managed WordPress installation into a high-performance platform capable of handling traffic spikes while keeping resource usage low. The steps above cover installation, configuration, and validation for the two most common Linux families used by AtoZNode’s managed hosts. Once set up, monitor hit rates and cache headers periodically; a healthy cache will show a growing number of hits and a steady reduction in database load. With these layers in place, your WordPress site will deliver faster page loads, better user experience, and lower server costs—all without sacrificing the flexibility that makes WordPress popular.