WordPress’s default object cache is in-memory and dies at the end of every PHP request, so the next request rebuilds the same query results and transients from scratch. Adding a persistent object cache backend — Redis or Memcached — lets LSCWP store those results across requests and dramatically reduces database load on busy sites. This article covers how to wire each backend, what differs between them, and how to confirm the cache is active.
How to verify
Check whether a persistent object cache is already active:
wp cache type
# Should return: Redis Object Cache or Memcached Object Cache or Default
If Redis is installed on the server:
redis-cli ping
# PONG
redis-cli info server | grep redis_version
If Memcached is installed:
echo "stats" | nc 127.0.0.1 11211 | head -10
After configuration, verify LSCWP is sending to the backend:
redis-cli monitor &
curl -s https://example.com > /dev/null
# You should see SET/GET calls for WordPress object cache keys
What’s happening
WordPress’s object cache API (wp_cache_get, wp_cache_set) uses a drop-in file — wp-content/object-cache.php — to delegate storage to a backend. Without a drop-in, WordPress uses the in-memory non-persistent implementation baked into core.
LSCWP ships its own object cache drop-in that speaks to Redis or Memcached using PHP extension calls (phpredis or the Memcached PECL extension). When the LSCWP object cache is configured and the drop-in is installed, every wp_cache_* call routes through it.
Redis vs Memcached — practical differences:
| Factor | Redis | Memcached |
|---|---|---|
| Data types | Strings, hashes, lists, sets | Strings only |
| Persistence | Optional (RDB/AOF) | None — data lost on restart |
| Clustering | Native Redis Cluster / Sentinel | Third-party or single-node only |
| PHP extension | phpredis (ext-redis) | php-memcached (PECL) |
| Recommended for WP | Yes — supports WooCommerce sessions and transients natively | Acceptable for simpler sites |
For most WordPress deployments, Redis is the right choice. WooCommerce session data, action scheduler transients, and complex query results benefit from Redis’s richer data structures. Memcached is faster at simple key-value lookups but loses data on any restart and cannot be clustered without external coordination.
The procedure
Step 1 — Install the backend service.
On Ubuntu/Debian with cPanel or a standalone server:
# Redis
apt-get install redis-server
systemctl enable --now redis-server
# Memcached
apt-get install memcached php-memcached
systemctl enable --now memcached
On cPanel, Redis can also be installed through the WHM plugin manager or via yum install redis on RHEL-based systems.
Step 2 — Install the PHP extension.
LSCWP requires ext-redis for the Redis backend:
# Via cPanel EasyApache 4
/scripts/phpextensionmgr install phpredis
# Or via PECL
pecl install redis
# Then add extension=redis.so to your php.ini
For Memcached:
pecl install memcached
# Add extension=memcached.so to php.ini
Confirm the extension is loaded:
php -m | grep -i redis
php -m | grep -i memcached
Step 3 — Configure LSCWP.
Navigate to LiteSpeed Cache → Cache → Object. Set:
- Object Cache — On
- Method — Redis or Memcached
- Host —
127.0.0.1(or the Redis/Memcached server IP for remote backends) - Port —
6379for Redis,11211for Memcached - Database — Redis database index (0–15); use 1 or higher if you share the Redis instance with other applications
- Password — Enter the Redis
requirepassvalue if authentication is configured - Cache Timeout — 3600 seconds is a practical default; match to your expected transient lifetime
Step 4 — Install the drop-in.
LSCWP installs the drop-in automatically when you save Object Cache settings. Verify:
ls -la /path/to/wordpress/wp-content/object-cache.php
# Should be a symlink or file from litespeed-cache
head -3 /path/to/wordpress/wp-content/object-cache.php
# Should mention LiteSpeed
If the file is missing, go to LiteSpeed Cache → Toolbox → Object Cache and click “Enable.”
Step 5 — Test.
wp cache type
# Redis Object Cache
wp cache flush
wp option update test_key test_value
wp cache get test_key
Monitor Redis to confirm WordPress is writing:
redis-cli monitor | grep -i wordpress
Common pitfalls
wp cache type still returns Default after setup. The object-cache.php drop-in is missing or conflicts with another plugin’s drop-in (W3TC, Redis Object Cache plugin). Remove any competing drop-in files before enabling LSCWP’s.
Redis connection refused. Redis is bound to 127.0.0.1 and the PHP process runs in a container or under a different network namespace. Check redis.conf for bind directive. On cPanel with CageFS, the socket path must be accessible inside the cage.
High Redis memory usage. WordPress stores a large number of transients that are never explicitly deleted. Run redis-cli info memory to assess usage. Enable maxmemory and maxmemory-policy allkeys-lru in redis.conf to cap usage and evict the least-recently-used keys.
Object cache not persisting session data. WooCommerce stores sessions in the database by default. The object cache only stores what WordPress’s cache API explicitly writes. Session storage is a separate setting in WooCommerce → Settings → Advanced.
Memcached dropping data unexpectedly. Memcached uses a slab allocator and data is silently evicted under memory pressure without any error. If you need reliability, switch to Redis.
Object cache configuration is one of the higher-leverage changes in a WordPress performance stack. Stack Harbor wires Redis and Memcached backends, validates extension availability, and monitors cache hit rates as part of managed operations. If object cache health is a concern for your environment, start there.