Cache and speed for WordPress

Sometimes, it’s quicker to use WordPress instead of another system to do a blog.
Now, it’s time to have a cache and gain good improvement in 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 the cache inside Redis after posting, and commenting… and all readers will go to Redis. It’s a good improvement and a new way to not 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 performance:

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

Don’t forget to protect your WordPress