How to Speed Up WordPress with Cloudflare, Varnish and Redis on CloudPanel

Set up a three-layer WordPress caching stack using Cloudflare, Varnish, and Redis Object Cache on CloudPanel for faster load times and lower server load.

How to Speed Up WordPress with Cloudflare, Varnish and Redis on CloudPanel

WordPress hosting on a VPS can get slow under real traffic if you’re not caching. CloudPanel ships with Varnish and Redis already installed, so you just need to wire them up correctly with some free plugins.

Here’s the setup I use: Cloudflare sits at the edge and caches pages globally, Varnish handles cache on your own server for requests that miss Cloudflare, and Redis stores PHP objects and database queries in memory so PHP executions are fast.

Hetzner VPS Hostinger VPS DigitalOcean $100 Free Vultr $100 Free

How the layers work together

Each layer handles a different type of request:

  1. Cloudflare — visitors hit Cloudflare first. If the page is cached on their CDN, it’s served from the nearest edge node without touching your server.
  2. Varnish — if the page isn’t in Cloudflare’s cache (first visit, post-publish, dynamic content), the request hits Varnish on your server. Varnish serves the cached HTML without running PHP.
  3. Redis — when Varnish needs to generate a fresh page, PHP talks to Redis for object and query caching instead of hitting MySQL repeatedly.

The result is fast loads for returning visitors and manageable server load during traffic spikes.

Plugins needed

Three free plugins handle everything:

  • CLP Varnish Cache — tells WordPress to purge Varnish when content changes. Install and activate, no configuration needed.
  • Redis Object Cache (v2.7.0) — connects WordPress to Redis. After activating, go to Settings → Redis and click Enable Object Cache. There’s also a paid version (Object Cache Pro) with WooCommerce optimizations and cache analytics, but the free version works well for most sites.
  • Super Page Cache for Cloudflare — links WordPress to Cloudflare’s cache and handles cache invalidation on publish. Free alternative to Cloudflare APO ($5/month).

Varnish setup in CloudPanel

Enable Varnish for your site in CloudPanel:

CloudPanel Varnish cache settings for a WordPress site

In CloudPanel, go to your site’s settings and enable Varnish Cache. The CLP Varnish Cache plugin handles automatic purging when you publish or update content.

Cloudflare plugin setup

In Super Page Cache for Cloudflare settings:

  1. Add your Cloudflare API token or Global API key
  2. Select your domain from the zone list
  3. Set caching mode to “Standard” and enable the page cache
  4. Configure bypass rules for WooCommerce cart/checkout if needed

The plugin creates a cached version of each page on Cloudflare’s CDN and purges it automatically when the page changes.

A note on dynamic content

This stack works well for mostly static content — blog posts, landing pages, static product pages. If you have pages with per-user content (cart, logged-in user data, personalized elements), make sure to configure bypass rules in both the Cloudflare plugin and Varnish settings. Serving cached pages to logged-in users causes obvious problems.

Check CloudPanel Varnish Cache setup for detailed Varnish configuration options.

Cloudflare APO vs Super Page Cache plugin

Cloudflare APO (Automatic Platform Optimization) costs $5/month and caches HTML at Cloudflare’s edge without needing a plugin. It works well but costs money. The Super Page Cache for Cloudflare plugin does roughly the same thing for free using the Cloudflare API. Both approaches cache full pages on Cloudflare and purge on publish.

If you’re already paying for Cloudflare Pro ($20/month), APO is included for free. If you’re on the free Cloudflare plan, the Super Page Cache plugin is the better deal.

When this stack isn’t enough

This three-layer setup handles most WordPress sites well. If you’re still hitting performance walls, the next steps are:

  • Upgrade to a bigger VPS (more CPU cores help with uncached requests)
  • Use a dedicated CDN like BunnyCDN or KeyCDN alongside Cloudflare
  • Switch to a purpose-built caching plugin like FlyingPress or LiteSpeed Cache if your host supports it
  • Look at Object Cache Pro if you run WooCommerce with heavy database load