WordPress

How to Make WordPress Faster with W3 Total Cache and Cloudflare

Exactly which W3 Total Cache settings to turn on, which to leave alone, and how to connect Cloudflare without the redirect loop that catches everyone.

W3 Total Cache and Cloudflare speeding up a WordPress site

W3 Total Cache is powerful and has hundreds of settings. That combination is why so many sites end up slower, or broken, after installing it.

This guide gives you the exact settings to enable, the ones to leave alone, and the Cloudflare configuration that avoids the redirect loop almost everyone hits once.

Before you install anything

Two checks, both worth a minute.

Is your host running LiteSpeed? Look in cPanel, or check the server header. If it is, install LiteSpeed Cache instead and stop reading here — it is free, faster than W3TC on that stack, and far simpler.

Do you already have a caching plugin? Remove it completely. Two caching plugins fight, serve stale pages and create bugs that are genuinely hard to trace. Deactivating is not enough — delete it.

Also take a backup. Caching plugins write to .htaccess and wp-config.php.

Part 1: W3 Total Cache

Install from Plugins → Add New, activate, and skip the setup wizard — we will set things deliberately.

General Settings: what to enable

SettingTurn on?Why
Page CacheYes — Disk: EnhancedThe whole point. Serves saved HTML instead of rebuilding.
MinifyNo, at firstBreaks more sites than it speeds up. Add later, carefully.
Opcode CacheYes, if offeredFree speed, nothing to break.
Database CacheNo on shared hostingDisk-based DB cache often makes things slower.
Object CacheNo on shared hostingSame reason. Yes on a VPS with Redis.
Browser CacheYesTells browsers to keep files. Big repeat-visit gain.
CDNLaterCloudflare is configured separately below.
Lazy LoadNoWordPress already does this.

Save, then empty all caches from the top bar. Test the site now, before adding anything else.

Page Cache settings

Under Performance → Page Cache, enable:

  • Cache front page
  • Cache feeds
  • Cache SSL (HTTPS) requests
  • Don't cache pages for logged in users — essential, or admins see stale pages and editors get confused

If you run a shop, add the cart, checkout and account pages to Never cache the following pages. A cached cart shows one customer another customer's basket.

Browser Cache settings

Under Performance → Browser Cache, enable for all three sections:

  • Set expires header
  • Set cache control header
  • Enable HTTP gzip compression

Minify — only after everything else works

This is where sites break. If you want to try it:

  1. Enable Minify in General Settings, mode Manual, not Auto
  2. Start with HTML only. Test the site.
  3. Add CSS. Test again.
  4. Add JS last, and test hardest — this is what breaks sliders, menus and forms.
  5. If anything breaks, turn JS minify off and leave it off. The gain is small.

Test in a private window. Logged-in pages are not cached, so you will not see the problem your visitors see.

Part 2: Cloudflare

Cloudflare serves your files from a location near the visitor, and gives free SSL and basic attack protection.

Set it up

  1. Create a free account at cloudflare.com and add your domain
  2. It scans your existing DNS records — check them carefully, especially mail records
  3. Change your nameservers at your registrar to the two Cloudflare gives you
  4. Wait for activation, usually minutes to a few hours

The SSL setting that causes the redirect loop

This is the one. Go to SSL/TLS → Overview.

ModeUse it?
OffNo
FlexibleNo — this causes the loop
FullAcceptable
Full (strict)Yes, if you have a real certificate

Flexible means Cloudflare talks to your server over plain HTTP. Your server sees an insecure request, redirects to HTTPS, Cloudflare forwards it again over HTTP, and round it goes. That is the "too many redirects" error.

Get a free certificate on the server first — see the WordPress SSL guide — then set Full (strict).

The rest of the Cloudflare settings

  • SSL/TLS → Edge Certificates: turn on Always Use HTTPS and Automatic HTTPS Rewrites
  • Speed → Optimization: enable Brotli
  • Caching → Configuration: Caching Level Standard, Browser Cache TTL 4 hours or more
  • Rocket Loader: leave off. It reorders JavaScript and breaks themes regularly.
  • Auto Minify: leave off if W3TC is already minifying. Never both.

Stop Cloudflare caching your admin area

Go to Rules → Page Rules and add:

URL:      yourdomain.com/wp-admin/*
Settings: Cache Level → Bypass

Add a second for yourdomain.com/wp-login.php*. Without these, logging in behaves strangely and changes appear not to save.

Connect Cloudflare to W3TC

Optional but useful: in Performance → Extensions, enable the Cloudflare extension and enter your account email and API token.

Once connected, clearing the W3TC cache also purges Cloudflare, which saves the "why is my change not showing" confusion.

Test it properly

  1. Open the site in a private window — logged-in pages are not cached
  2. Check a post, a page, the contact form, and the search
  3. If you have a shop, add something to the cart and reach checkout
  4. Run PageSpeed Insights on mobile
  5. Confirm cf-cache-status appears in the response headers

Common problems

"Too many redirects"

Cloudflare SSL is on Flexible. Change to Full (strict). This is the single most common Cloudflare problem.

The site looks unstyled

Minify broke the CSS. Turn Minify off, empty all caches, purge Cloudflare. Then reintroduce it one type at a time.

Menus, sliders or forms stopped working

JS minify or Rocket Loader. Turn both off.

My changes do not appear

Clear in this order: W3TC empty all caches, Cloudflare purge everything, browser hard refresh. Skipping the middle step is the usual mistake.

Logged-in users see the wrong content

"Don't cache pages for logged in users" is off. Turn it on, and add the page rule bypassing /wp-admin/.

The site got slower

Usually Database Cache or Object Cache on shared hosting. Turn both off.

WooCommerce shows the wrong cart

Cart, checkout and account pages are being cached. Add them to the never-cache list immediately.

Is W3 Total Cache the right choice?

SituationBetter option
Host runs LiteSpeedLiteSpeed Cache — free and faster
You want simpleWP Super Cache
You want controlW3 Total Cache
You want to pay for simpleWP Rocket

W3TC is the most capable of the free options and the easiest to misconfigure. If the settings above feel like a lot, WP Super Cache gets you 80 percent of the benefit with four checkboxes.

And remember caching is only one part. If images are uncompressed or the host is slow, no caching plugin saves you — see how to increase WordPress speed for the full diagnosis.

Where to go next

Questions people ask

Why do I get "too many redirects" after adding Cloudflare?
Cloudflare SSL is set to Flexible, which means it talks to your server over plain HTTP. Your server redirects to HTTPS, Cloudflare sends it back over HTTP, and the loop repeats. Install a real certificate on the server and set Cloudflare to Full (strict).
Which W3 Total Cache settings should I enable?
Page Cache set to Disk Enhanced, Browser Cache, and Opcode Cache if offered. Leave Minify off at first, and leave Database Cache and Object Cache off on shared hosting — both often make things slower there.
Why did my site break after enabling W3 Total Cache?
Almost always Minify, and usually the JavaScript part, which breaks sliders, menus and forms. Turn Minify off, empty all caches, and reintroduce it one type at a time starting with HTML.
Should I use W3 Total Cache or LiteSpeed Cache?
If your host runs LiteSpeed, use LiteSpeed Cache. It is free, faster on that stack and far simpler to configure. W3 Total Cache is for hosts that do not run LiteSpeed.
Can I use two caching plugins together?
No. They conflict, serve stale pages and create bugs that are very hard to trace. Pick one, and delete the other rather than only deactivating it.
Why are my changes not showing on the site?
You are seeing a cached copy. Clear in this order: empty all caches in W3TC, purge everything in Cloudflare, then hard refresh the browser. Skipping the Cloudflare step is the usual mistake.
Should I turn on Cloudflare Rocket Loader?
No. Rocket Loader reorders JavaScript execution and regularly breaks themes, sliders and forms. The speed gain is small compared with the number of things it breaks.
How do I stop Cloudflare caching my WordPress admin?
Add a page rule for yourdomain.com/wp-admin/* with Cache Level set to Bypass, and a second for wp-login.php. Without these, logging in behaves strangely and changes appear not to save.
Why does my WooCommerce cart show the wrong items?
The cart, checkout and account pages are being cached, so one customer is seeing another customer's page. Add all three to the never-cache list in W3 Total Cache immediately.
Is Cloudflare free good enough?
For most sites, yes. The free tier gives you the CDN, free SSL, Brotli compression and basic attack protection. Paid plans mainly add image optimisation and advanced rules that small sites do not need.

Written by Habib Baloch

I build Android apps, websites and Ubuntu servers, and write down exactly how I did it.

Ask me about this guide →