A cache shared by all your web servers keeps WordPress’s object cache warm through deploys and across instances. Create the cache in the VPC your WordPress instances are in, then set up one of these plugins.
Valkey with Redis Object Cache
Redis Object Cache works with Valkey over TLS, with a
username and password. It needs the PHP redis extension (phpredis), Predis or Relay.
-
Download the EZGH CA bundle to each web server:
sudo curl -fsSo /etc/ssl/certs/ezgh-caches.pem https://get.ezghcloud.com/caches/ca-bundle.pem -
Read the cache’s endpoint and the
defaultuser’s Secret:ezgh caches get cch_4k2m9x0a7qpe ezgh secrets read sec_a1b2c3d4e5f6 --field password --format rawTo read the password on an instance without handling it yourself, see Read a secret on an instance.
-
Add to
wp-config.php, above/* That's all, stop editing! */:define( 'WP_REDIS_SCHEME', 'tls' ); define( 'WP_REDIS_HOST', 'cache-hylq6kelvuwvn2ks4yqhp4jaqu.us-west-1.ezghcompute.com' ); define( 'WP_REDIS_PORT', 6379 ); define( 'WP_REDIS_PASSWORD', [ 'default', '<password from the Secret>' ] ); define( 'WP_REDIS_SSL_CONTEXT', [ 'cafile' => '/etc/ssl/certs/ezgh-caches.pem', 'verify_peer' => true, 'verify_peer_name' => true, ] ); define( 'WP_REDIS_TIMEOUT', 1 ); define( 'WP_REDIS_READ_TIMEOUT', 1 );WP_REDIS_PASSWORDis the username and the password. With only a password, thedefaultuser is used. -
In WordPress, open Settings › Redis and choose Enable Object Cache. The status shows Connected.
Several sites can share one cache: give each its own WP_REDIS_PREFIX, and its own
user if you rotate their passwords separately.
Memcached with W3 Total Cache
The PHP memcached extension doesn’t support TLS, so WordPress connects to Memcached on port
11212, without TLS, inside your VPC. That port takes a username and password over Memcached’s
binary protocol (SASL). It’s on while the cache’s plaintextPort is true, as it is by default.
W3 Total Cache supports this. It needs the PHP
memcached extension built with SASL support, as distribution packages are (php-memcached on
Ubuntu and Debian).
- Read the cache’s endpoint and the
defaultuser’s Secret, as above. - In WordPress, open Performance › General Settings, turn on Object Cache, and pick Memcached as its method.
- Open Performance › Object Cache. Set Memcached hostname:port to the endpoint and port
11212, for example
cache-hylq6kelvuwvn2ks4yqhp4jaqu.us-west-1.ezghcompute.com:11212. Turn on Use binary protocol, and enter the username and password. - Choose Test to check the connection, then Save all settings.
Plugins that use the older PHP memcache extension, such as the memcached object-cache drop-in,
can’t send a username and password, so they can’t connect.
A Memcached cache starts empty after a failover or maintenance. WordPress fills it again as pages are served.