OK, I spent a lot of time trying to figure both the Redis cache which caches various HMTL elements and the lower level PHP Opcode cache. For instance making sure there is no swap file so that Redis doesn’t thrash caching to disk instead of memory.
Right now depending on the host, I’m using three different Redis caches:
- Cloudways Digital Ocean. They come with a free copy of Object Cache Pro which is nice. That’s a real value as it costs $79/month otherwise.
- Digital Ocean itself. I manually installed Redis on my old Ubuntu 20.04 installation
- Inmotion Hosting. Because its a share instance, you can’t get redis caching
Remove Object Cache Pro and install Redis Cache
I have already done this installation once and it is decently hairy.
apt update
apt install redis-server
# now edit /etc/redis/redis.conf
# make sure that bind is wonly to 127.0.0.1 ::1
# make sure supervised systemd is there
systemctl restart redis.service
systemctl status redis
redis-cli
ping
## you should see PONG come out
set test "It's working!"
get test
## should see "It's working!"
exit
systemctl restart redis
This didn’t work. Another guide said to add systemctl enable redis-server
Now install Redis Cache Plugin and change wp-config.php and open the port
Thgat is not all though, redis is up, but you need a Redis Object Cache
plugin and some config glue:
# you shouldn't need this but check in wp-config.php
define('WP_REDIS_HOST', '127.0.0.1');
define('WP_REDIS_PORT', 6379);
# now open the firewall
ufw allow 6379
ufw reload
systemctl restart apache2
apt install net-tools
sudo netstat -lnp | grep redis
# you should see 127.0.0.1:6379 on listen
Note that some of the manuals say to create a password on the Redis Cache, but I left this off as it is just local to the machine.
Do Not Forget the OP Cache Manager
This is pretty easy, just install the OPcache Manager
and it will look at the PHP instructions and cache them.
NOte that Op code caching is on by default so this is just for logging
Leave a Reply