WPFleet provides comprehensive caching capabilities using a two-tier approach:
- Object Cache: Redis Object Cache (via Valkey)
- Full-Page Cache: Cache Enabler plugin
This document describes how to manage caching for your WordPress sites.
The cache-manager.sh script provides an interface for managing both object caching and full-page caching across all WordPress sites in your WPFleet installation.
- Valkey: Redis-compatible in-memory data store used for object caching
- Redis Object Cache Plugin: WordPress plugin that integrates WP object cache with Valkey
- Cache Enabler: Lightweight full-page caching plugin
./scripts/cache-manager.sh setup example.comThis will:
- Install and activate Redis Object Cache plugin
- Enable object caching connection to Valkey
- Install and activate Cache Enabler plugin
- Configure both plugins for optimal performance
# Purge all cache for a specific site
./scripts/cache-manager.sh purge example.com
# Purge all cache across all sites
./scripts/cache-manager.sh purge-all
# Purge cache for a specific URL
./scripts/cache-manager.sh purge-url example.com /blog/my-post/# Global cache statistics
./scripts/cache-manager.sh stats
# Per-site statistics
./scripts/cache-manager.sh stats example.com
# List all cached sites
./scripts/cache-manager.sh listSets up full-page caching (Redis Object Cache + Cache Enabler) for a site.
./scripts/cache-manager.sh setup example.comInstalls only the Redis Object Cache plugin.
./scripts/cache-manager.sh install-object example.comInstalls only the Cache Enabler plugin.
./scripts/cache-manager.sh install-page example.comPurges all cache across all sites.
./scripts/cache-manager.sh purge-allUse cases:
- After Valkey configuration changes
- System-wide cache invalidation
- Troubleshooting cache issues
Purges all cache for a specific site.
./scripts/cache-manager.sh purge example.comUse cases:
- After theme or plugin updates
- After content changes
- Site-specific troubleshooting
Purges cache for a specific URL.
./scripts/cache-manager.sh purge-url example.com /blog/my-post/Use cases:
- After editing a specific page/post
- Selective cache invalidation
- Testing changes to individual pages
Enables caching for a site (same as setup).
./scripts/cache-manager.sh enable example.comDisables caching for a site.
./scripts/cache-manager.sh disable example.comNote: This will:
- Deactivate Redis Object Cache plugin
- Deactivate Cache Enabler plugin
- Purge all cached data for the site
Pre-warms the cache by visiting pages.
./scripts/cache-manager.sh warm example.comHow it works:
- Fetches the sitemap.xml
- Visits up to 50 URLs from the sitemap
- Pre-generates cached pages
Best used:
- After purging cache
- During low-traffic periods
- Before expected traffic spikes
Shows global Valkey cache statistics.
./scripts/cache-manager.sh statsDisplays:
- Valkey server information
- Memory usage statistics
- Cache hit/miss rates
- Per-site cache key counts
Shows cache statistics for a specific site.
./scripts/cache-manager.sh stats example.comDisplays:
- Object cache key count
- Sample cache keys
- Redis Object Cache plugin status
- Cache Enabler status
- Page cache size and file count
Lists all sites with their caching status.
./scripts/cache-manager.sh listOutput format:
✓ example.com (object,page)
✓ staging.example.com (object)
✗ dev.example.com (no cache)
When creating a new WordPress site, caching is automatically configured:
# Clean install automatically includes cache setup
./scripts/site-manager.sh add example.comFor imported sites:
# Import site first
./scripts/site-manager.sh add example.com --import-from
# Then setup caching
./scripts/cache-manager.sh setup example.comValkey is configured in docker/valkey/valkey.conf:
# Memory management
maxmemory 256mb
maxmemory-policy allkeys-lru
Key settings:
maxmemory: Maximum memory for cache (adjust based on available RAM)maxmemory-policy: LRU eviction when memory limit is reached- Password protection enabled via
REDIS_PASSWORDenvironment variable
When a site is created, wp-config.php includes:
// Redis Object Cache (Valkey)
define( 'WP_REDIS_HOST', 'valkey' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_PASSWORD', 'your_password' );
define( 'WP_REDIS_PREFIX', 'wp_sitename' );
define( 'WP_REDIS_DATABASE', 0 );
// Enable WordPress object cache
define( 'WP_CACHE', true );Each site uses a unique cache prefix based on its database name:
- Domain:
example.com→ Prefix:wp_example_com: - Domain:
my-site.org→ Prefix:wp_my_site_org:
This ensures cache isolation between sites.
-
Monitor hit rates: Aim for >80% hit rate
./scripts/cache-manager.sh stats
-
Adjust Valkey memory: Edit
.envVALKEY_MEM_LIMIT=512m # Increase if needed -
Use persistent connections: Already configured in wp-config.php
-
Warm cache after purges:
./scripts/cache-manager.sh purge example.com ./scripts/cache-manager.sh warm example.com
-
Exclude dynamic pages: Configure in WordPress admin → Settings → Cache Enabler
-
Monitor cache size:
./scripts/cache-manager.sh stats example.com
Always purge after:
- Theme changes
- Plugin activation/deactivation
- WordPress core updates
- Content updates that affect multiple pages
Selective purge for:
- Individual post/page edits
- Comment moderation
- Widget changes
-
Check plugins are active:
./scripts/cache-manager.sh stats example.com
-
Verify Valkey connection:
docker exec wpfleet_valkey valkey-cli -a $REDIS_PASSWORD ping
-
Check WordPress object cache:
./scripts/wp-cli.sh example.com redis status
-
Manually purge:
./scripts/cache-manager.sh purge example.com
-
Check permissions:
docker exec wpfleet_frankenphp chown -R www-data:www-data /var/www/html/example.com
-
Check Valkey memory:
./scripts/cache-manager.sh stats
-
Reduce maxmemory: Edit
docker/valkey/valkey.conf -
Purge old cache:
./scripts/cache-manager.sh purge-all
-
Warm the cache:
./scripts/cache-manager.sh warm example.com
-
Check cache hit rate:
./scripts/cache-manager.sh stats example.com
-
Verify no cache conflicts: Check for other caching plugins
Add to cron:
# Warm cache daily at 3 AM
0 3 * * * /path/to/wpfleet/scripts/cache-manager.sh warm example.com#!/bin/bash
# Monitor cache hit rate and alert if low
STATS=$(./scripts/cache-manager.sh stats)
HIT_RATE=$(echo "$STATS" | grep "hit_rate" | awk '{print $2}' | sed 's/%//')
if (( $(echo "$HIT_RATE < 70" | bc -l) )); then
echo "Cache hit rate is low: $HIT_RATE%"
# Send alert...
fi# In deployment scripts
./scripts/cache-manager.sh purge example.com
./scripts/cache-manager.sh warm example.com-
Password Protection: Valkey requires authentication (configured via
REDIS_PASSWORD) -
Dangerous Commands Disabled: FLUSHALL, FLUSHDB, CONFIG, and KEYS commands are disabled in Valkey
-
Network Isolation: Valkey is only accessible within the Docker network
-
Cache Isolation: Each site has a unique cache prefix
Typical performance improvements with caching enabled:
- Object Cache: 50-70% reduction in database queries
- Page Cache: 80-95% reduction in PHP execution time
- Combined: 10-50x faster page load times (depending on site complexity)
The cache-manager.sh script returns exit codes:
0: Success1: Error (domain not found, Docker not running, etc.)
All output uses colored formatting:
- Green (✓): Success
- Yellow (⚠): Warning
- Red (✗): Error
- Blue: Headers/Information
For issues or questions:
- Check WPFleet GitHub issues
- Review Redis Object Cache plugin documentation
- Review Cache Enabler plugin documentation
- Check Valkey logs:
docker logs wpfleet_valkey