wp cache type
Overview
Identify whether WordPress is using the default non-persistent in-memory cache or a persistent backend (Redis, Memcached). Essential first step for cache debugging and server configuration audits.
What It Does
wp cache type reads the $_wp_using_ext_object_cache global and outputs the name of the active cache implementation class.
Syntax
wp cache type
Basic Usage
wp cache type
Output without persistent cache:
Default
Output with Redis Object Cache plugin:
WP_Object_Cache (Redis)
Output with Memcached:
WP_Object_Cache (Memcached)
Real-World Scenarios
Scenario 1: Verify cache is installed after Redis setup
# After installing Redis and the plugin
wp plugin install redis-cache --activate
wp redis enable
wp cache type
# Expected: WP_Object_Cache (Redis)
Scenario 2: Audit cache configuration on multiple sites
for path in /var/www/site1 /var/www/site2 /var/www/site3; do
TYPE=$(wp cache type --path="$path" 2>/dev/null)
echo "$path: $TYPE"
done
Output:
/var/www/site1: Default
/var/www/site2: WP_Object_Cache (Redis)
/var/www/site3: WP_Object_Cache (Redis)
Scenario 3: Conditional flush based on cache type
TYPE=$(wp cache type)
if [[ "$TYPE" == "Default" ]]; then
echo "No persistent cache — flush is request-scoped only."
else
wp cache flush
echo "Persistent cache flushed: $TYPE"
fi
Cache Type Comparison
| Type | Persists Between Requests | Shared Across Servers | Recommended |
|---|---|---|---|
Default | ❌ No | ❌ No | Dev only |
| Redis | ✅ Yes | ✅ Yes (single instance) | Production |
| Memcached | ✅ Yes | ✅ Yes (cluster) | Production |
Best Practices
- Always check cache type before flush debugging — if
Default, wp cache flush has no meaningful effect between real requests. - Use Redis on all production WordPress sites — it dramatically reduces database load.
- Include cache type in server audits — a site running
Defaulton a high-traffic host is a common performance gap.
Quick Reference
wp cache type # Check active cache backend
wp cache flush # Flush cache after confirming backend
wp plugin list | grep cache # Find installed cache plugins
Next Steps
wp cache flush— clear the cache once you know what's running.wp cache get— inspect specific cached values.