Cache and speed for WordPress

cloudflare nginx redis and wordpress logos

Sometimes, it’s quicker to spoon WordPress instead of another system to do a blog.
Now, it’s time to have a cache and gain good improvement about rendering.

1. The right web server

I use Nginx with PHP-FPM to be the secure base: 2019, no more Apache2

It’s also possible to implement cache at the Nginx level but I don’t use it. I prefer improvement related to metrics.

2. JS/CSS/HTML optimizer (optional)

I tested Autoptimize and finally, it’s interesting when you use Elementor.
This blog doesn’t use Autoptimize because during the test: 0kB… impossible to optimize more.

3. In-memory caching

It’s time to use Redis with Redis Cache.

WordPress will refresh cache inside Redis after posting, commenting… and all readers will go to Redis. It’s a good improvement and a new way to don’t use Varnish or Nginx cache immediately.

4. CDN

It’s the last step with Cloudflare.
The free version works great for personal sites/blogs.

Other improvements

What are the next possible steps to improve performances:

  • replace PHP-FPM with HHVM
  • replace WordPress code (core + plugin) to read from Redis by Lua code directly inside Nginx configuration
  • activate Nginx cache
  • Migrate WordPress to a static website (Jekyll, Hugo)
  • Build a 2 steps prod :
    – edit and publish to WordPress offline (internal)
    – CI/CD to convert WordPress to static website and push rendered static website to a public server

Don’t forget to protect your WordPress