The Ideal W3 Total Cache Settings With Cloudflare And StackPath CDN Instructions — Last Updated 2020 With Latest Version 0.14.2

Not sure if you have the best W3 Total Cache settings?

I generally don’t recommend W3 Total Cache since it doesn’t support database cleanup, heartbeat control, optimizing Google Fonts video optimization, or NGINX + memcached (only available with the premium version). While W3 Total Cache is free, WP Rocket is better since it has these built-in. That’s why it yields faster load times and is rated the #1 cache plugin in most Facebook polls. But if you insist on free, use this tutorial to set up your W3 Total Cache settings.

This tutorial shows you how to set up the performance tabs then add Cloudflare’s free CDN or StackPath‘s premium CDN. Many W3 Total Cache settings are preset (shown in the “Install” tab), but not all of them. For hosting, I recommend DigitalOcean on Cloudways especially over SiteGround, EIG, and GoDaddy (TLDR: Cloudways + WP Rocket is a much faster configuration). They’re what I use; see my GTmetrix report or click through my posts to see how fast they load.

W3-Total-Cache-Settings

 

W3 Total Cache Dashboard

 

Download my recommended W3 Total Cache settings here (you’ll need a Dropbox account). Upload the file under Performance → General Settings → Import / Export Settings. Check your site to make sure everything is OK. You will still need to configure a CDN, activate extensions, and add your sitemap URL (under Page Cache). This file was last updated on March, 18, 2019.

 

1. General Settings

Important notes about the W3 Total Cache general settings:

  • Cache method: use disk enhanced for shared hosting, memcached for cloud hosting.
  • Database cache: leave disabled, it overloads the server especially on shared hosting.
  • Object cache: leave disabled, it will usually slow down the website and the dashboard.
  • CDN: enable if you plan on using StackPath’s CDN (though you can just use Cloudflare).
  • Lazy loading: delays loading of images and fixes the lazy load item in PageSpeed Insights.
  • Fragment cache: only available with W3 Total Cache Pro and usually for dynamic sites.
  • Google PageSpeed Widget: I recommend the GTmetrix plugin for monitoring instead.

W3 Total Cache General Settings 1

 

2. Page Cache

Important notes about the W3 Total Cache page cache settings:

  • Don’t cache pages: you don’t want to cache pages for logged in users or user roles.
  • Rest API: the rest API can be disabled if you’re not using (check your website for errors).
  • Compatibility mode: enable, this is recommended in the Install tab by the developer.

W3 Total Cache Page Cache Settings

 

3. Minify Settings

The plugin developer says the recommended settings for minify, database, and object cache are preset. You can find these recommendations in the Install tab. The main things to tweak are the browser cache settings and set up a content delivery network like Cloudflare or StackPath.

minify settings

 

4. Database Cache

  • Leave as is (recommended by the developer).

 

5. Object Cache

  • Leave as is (recommended by the developer).

 

6. Browser Cache

Important notes about the W3 Total Cache browser cache settings:

  • Enable first 6 settings: enable these individually and test the results in GTmetrix.
  • Brotli compression: if using Cloudflare’s CDN, enable this in the Cloudflare dashboard.

W3 Total Cache Browser Cache Settings 1

Leave everything else including ‘expires header lifetime’ which the developer says is preset.

 

7. User Agent Groups

User Agent Groups are used to specify whether a mobile theme is used (if you have a mobile responsive website and are not using a plugin to create a mobile site, there is no need for this).

W3 Total Cache User Agent Groups

 

8. Referrer Groups

Referrer Groups are used to serve a unique cached version for users who come to your site through specific traffic sources (eg. Google or Bing). Most websites should leave this disabled.

W3 Total Cache Referrer Groups

 

Same concept as referrer groups, only it uses cookies instead to create a unique cached version for users who come to your site through specific cookies. Most sites should leave this disabled.

W3 Total Cache Cookie Groups

 

10. CDN

This section is specifically for StackPath’s CDN which they also have a tutorial for.

Cloudflare is set up differently and it has it’s own section. While most people only recommend using 1 CDN (usually Cloudflare since it’s free), I personally use both Cloudflare and StackPath. Both offload a ton of resources to their data centers and save bandwidth (screenshots below).

StackPath-Bandwidth-Savings

Step 1: Go to the W3 Total Cache General Settings and enable StackPath.

W3 Total Cache Enable CDN

Step 2: Sign up for StackPath, select API management from the dropdown menu (top right), then select Generate Credentials. Create a name (eg. W3TC) then StackPath will give you a Client ID and Client Secret. Copy/paste these into StackPath under CDN Settings → Authorize.

StackPath Credentials

Authorize

StackPath Credentials In W3TC

Step 3: In the W3 Total Cache CDN settings, use these:

W3 Total Cache CDN Settings 1

Step 4: In StackPath go to CDN → Cache Settings, then click Purge Everything:

StackPath-Purge-Cache

Step 5: Run your site in GTmetrix and “content delivery network” should be green in YSlow.

CDN GTmetrix YSlow

CDN pointers from the plugin developer (found in Install tab) – if you do not use the Media Library, import your images etc into the default locations. Use the Media Library Import Tool on the “CDN” tab to do this. If you do not have a CDN provider, you can still improve your site’s performance using the “Self-hosted” method. On your own server, create a subdomain and matching DNS Zone record; e.g. static.domain.com and configure FTP options on the “Content Delivery Network” tab. Be sure to FTP upload the appropriate files, using the upload buttons.

 

11. Fragment Cache

Fragment cache is mainly used in dynamic sites. Instead of caching an entire page, individual sections (usually the heavy areas) are cached. You will need to upgrade to W3 Total Cache Pro to use fragment cache. They have recommendations on that page I linked to which makes the plugin aware if you’re grouping transients. However, you may need some coding experience.

W3 Total Cache Fragment Cache

 

12. User Experience

W3 Total Cache comes with basic lazy load settings which fixes the lazy load item in PageSpeed Insights. This delays loading of images until you scroll down and see them. It doesn’t optimize videos, so if you embed YouTube videos on your site, you will need an additional plugin for that.

W3 Total Cache Lazy Loading

 

13. Extensions

Active any extensions you’re using. In my case it would be Cloudflare and Yoast.

W3 Total Cache Extensions

 

14. Cloudflare CDN

Cloudflare is free with over 200+ data centers.

If you’re using Cloudflare, there is usually no need to use StackPath. Unlike StackPath, setting up Cloudflare is different and requires changing nameservers. When you’re done, be sure to login to your Cloudflare dashboard and add Page Rules which can improve speed and security.

Cloudflare-Bandwidth-Savings

Step 1: Sign up for a free Cloudflare account, add your site, and run the scan prompted by Cloudflare. You will eventually come to a page where Cloudflare assigns you 2 nameservers.

Cloudflare-GoDaddy-Nameservers

Step 2: Login to your domain registrar, find the area to change nameservers, and paste them here. Once this is done, you can go back to Cloudflare and click “Done, check nameservers.”

SiteGround-DNS-Records

Step 3: In the W3 Total Cache Extensions tab, activate Cloudeflare and click Settings.

Cloudflare Extension

Configure the Cloudflare settings (note: the only thing I changed is enabling hotlink protection).

W3 Total Cache Cloudflare Settings

Step 4: Login to your Cloudflare dashboard and go to Page Rules. Add these 3 page rules:

Page Rule 1: Cache Everything And Force HTTPS – cache your website aggressively.

http://*yourwebsite.com/*

Always-Use-HTTPS-Page-Rule

Page Rule 2: Secure The WordPress Admin And Bypass Cache – sets security level of the admin to high and bypasses Cloudflare’s cache in the admin, since you don’t want CDNs (or apps + performance features like Rocket Loader) running inside the admin.

yourwebsite.com/wp-admin*

WordPress-Admin-Page-Rule

Page Rule 3: Decrease Bandwidth Of WP Uploads – since the content in your WP Uploads folder does not change frequently, increasing Edge Cache TTL to a month can save on bandwidth, since the WP Uploads folder cache won’t be refreshed as often.

yourwebsite.com/wp-content/uploads*

WP-Uploads-Page-Rule

Once you’re done configuring your CDN(s), purge all caches in W3 Total Cache. If you don’t see this, there may be an ’empty all caches’ option in the dashboard tab. It can take up to 24 hours for Cloudflare nameservers to propagate, but you will get a confirmation email once complete.

 

15. Cloudways (The Host I Use)

Hosting recommendations are usually garbage.

Join the WordPress Hosting Facebook Group to get unbiased feedback. Most members (myself too) swear by Cloudways WordPress Hosting. Specifically DigitalOcean / Vultr High Frequency.

Yes, it’s a little more expensive at $10-$13/month, but we’re talking about speed here – not being cheap. With Cloudways, you have a choice of using DigitalOcean, Vultr High Frequency, Google Cloud, AWS, or Linode. These are worlds faster than shared hosting and can handle resource-intensive tasks much better (Elementor, Beaver, Divi, WooCommerce, AdSense, etc).

Cloudways makes it easy to test them out and see the difference in your load times: they do free migrations, monthly pricing, a Migrator plugin, and a promo code to save money: OMM25

Here’s what happened when I moved:

SiteGround vs Cloudways

GTmetrix tests are always different, but even posts with a huge page 2.70MB page size and 96 requests can often load in under 2s. I’ll also take a 148ms time to first byte any day of the week. That post has 70+ images, 480 comments (showing Gravatars), Font Awesome, and Elementor.

OMM-TTFB

The evidence is there:

Cloudways Response TimesCloudways-Migration-Result
Cloudways Google PageSpeed
WP Engine To Cloudways
DigitalOcean Pingdom Report
Hosting-Recommendation
Moving-From-WPX
SiteGround-Alternatives
Preferred-Web-Hosting
UntitledWPEngine-To-Cloudways
Godaddy DigitalOcean Migration
Cloudways Pingdom Load Times
Cloudways Pingdom Report
Elementor-Hosting
Web-Hosting-France
SiteGround-Alternative
VPS-Cloud-Hosting

 
This was a simple Pingdom test to measure load times of 16 WordPress hosts. I signed up for popular hosting companies then installed the same Astra Starter Site on each of them while measuring load times in Pingdom for 1 week at 30 minute check intervals. Some domains are still live (cwdoserver.com is hosted on a $10/month Cloudways DO plan and stgrndserver.com is hosted on SiteGround GrowBig). I cancelled most of them because it was getting expensive. Even when browsing through their pages or running your own tests, you can see the difference.

WordPress-Hosting-2020-Pingdom-Test

Hosting Companies You Should Avoid

  • SiteGround – they have gone completely downhill in recent years.
  • Bluehost – slow servers, owned by EIG, bad support, rated poorly in FB Groups.
  • HostGator – also owned by EIG with slow servers, bad support, CPU limit issues.
  • GoDaddy – top malware hosting network worldwide, rated poorly in FB groups.
  • Hostinger – they write fake reviews and vote for themselves in Facebook polls.
  • WP Engine – also not what it used to be, expensive and not even fast anymore.
  • *A2 Hosting – if you can’t afford Cloudways, A2 is still fast and uses LiteSpeed.

I use Cloudways because:

  • Even posts with a 2.70MB page size can load in under 2s
  • DigitalOcean and Vultr HF are miles faster than shared hosting.
  • It’s $10-$13/month (no yearly contracts or high renewal prices).
  • Varnish, Redis, and memcached are all built-in for higher performance.
  • You get to pick from DigitalOcean, Vultr HF, Linode, AWS, Google Cloud.
  • 4.8/5 star TrustPilot rating and highly recommended in Facebook Groups.
  • They have 25+ data centers between all their cloud hosting providers.
  • No CPU issues like on SiteGround, Bluehost, and other shared hosting.
  • SSL, staging, and backups are all very easy in the Cloudways dashboard.
  • Support used to be average, but is now really good as reflected on TrustPilot.
  • They offer a free migration but their Migrator plugin will also do the trick.
  • Adding a server, migrating your site, and the dashboard is actually very easy.
  • Mustasaam (their community manager) gave me peace of mind when moving.
  • Only complaint is they need to add LiteSpeed servers to their list of providers.

Affiliate Disclaimer – if you sign up for Cloudways using my affiliate link, I would seriously appreciate it. I don’t recommend bad hosting like many other affiliates. I also donate quite a bit to charity ($6,000 to GoFundMe so far) and your support would really help. I try to base my reviews not only from my experience, but real evidence from the overwhelming feedback in numerous Facebook Groups. It would mean a lot.

Just do your research and look at this Facebook thread.

 

35+ WP Speed Tips (My Full Guide)

Watch My Video – it’s a 42 minute video, but I cover pretty much everything (timestamps in video description) and you should learn a ton of great information on WordPress site speed:

 

Hire My WordPress Speed Optimizer

Still need help with your GTmetrix report? I’ve been working with Pronaya since 2011 (he’s the one who helped me get a such nice scores + load times. You can hire him by creating a profile on freelancer.com and searching for username bdkamol (see his portfolio). He’s $40/hour from Bangladesh (so there is a time change) and his email him is bdkamol@gmail.com. He has a perfect 5 star review on his profile. Serious inquiries only, and please don’t expect 100% scores if you’re using slow hosting, plugins, and theme. Please follow my WordPress speed guide first.

Pronaya-Kumar-S-Reviews

 

Frequently Asked Questions

🚀 Is W3 Total Cache the best cache plugin?

Most people prefer WP Rocket over W3 Total Cache since it comes with features not included with W3 Total Cache, and therefore yields better results in GTmetix. These features include database cleanup, hosting analytics locally, advanced lazy loading of images + videos, heartbeat control, and DNS prefetching. It's also easier to configure.

🚀 Should I use a CDN with W3 Total Cache?

Yes, Cloudflare's free CDN can make your site faster and more secure which you can set up by changing nameservers in your domain registrar, then configuring the Cloudflare settings in W3 Total Cache. Adding page rules in the Cloudflare dashboard is also recommended.

🚀 What happens if W3 Total Cache breaks my site?

The minification and combination settings in W3 Total Cache are usually the most common culprits of broken elements when using W3 Total Cache. Test each one of these carefully.

🚀 How do I clear cache once I'm done?

Go to the Performance settings, then click Purge Everything.

🚀 Do I need other speed plugins besides W3 Total Cache?

Yes, you should also install plugins for heartbeat control, database cleanup, image optimization, and either Asset CleanUp or Perfmatters to selectively disable plugins.

See Also: How I Got 100% GTmetrix Scores

That’s it! I know it can get a bit technical so if you have any questions just drop me a line in the comments. And if you enjoyed my tutorial, please give it a share. I would really appreciate that!

Cheers,
Tom

Subscribe
Notify of
guest
617 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments