How to Set Up the W3-Total-Cache Plugin

by Martin Malden

Tools for setting up. My Google Analytics keywords report is telling me that one of the more searched for items on this site is ‘how to set up W3-Total-Cache’ – so here goes.

Before starting, though, a word of caution: server configurations vary between hosting providers, so your first step should be to ask your hosting provider for their recommended settings.

Of course, some may not be familiar with the plugin, so won’t be able to help.

But there are many who are familiar with it, and following their guidelines will ensure your settings are optimized for the server your site is on.

My hosting provider, Hostgator, not only recommended W3TC, they gave me their recommended settings for it – that’s service!

With that in mind, I’ve described how I set up my version. But do remember that your server configuration may be different, so these may not be optimum for your site.

The current version of W3TC at the time of writing is 0.9.2.3. Recent upgrades of the plugin have brought some major changes, so you should review the settings and options each time there’s an upgrade.

And remember that if you change the theme you’re using you’ll need to add the new stylesheet URLs to the minify section.

W3-Total-Cache General Settings

So here are the settings I’ve used for W3TC:

General settings

Preview mode is enabled. This enables me to view any changes I’ve made before deploying them, to ensure they haven’t screwed up the site.

Page cache via disk (enhanced) is enabled

Minify is enabled, minify mode is manual, minify method is disk, HTML, JS and CSS minifiers are all default.

Database cache is enabled, method is disk.

Object cache is not enabled (recommendation from Hostgator, based on the server configuration).

CloudFlare is not enabled. The reason for this is that CloudFlare was originally a security and anti spam application and is part of the Honey Pot project.

This site is already part of the Honey Pot project through the Bad Behaviour plugin, so I don’t need CloudFlare.

However, if your site is not part of the Honey Pot project then it’s well worth looking at CloudFlare, especially as it gives you performance benefits as well.

Varnish. This is a server application so you need to know whether the server your site is on has Varnish installed.

Don’t enable this unless it’s installed on your server – you’ll need advice from your hosting provider.

Content Delivery Network. If you have a CDN you can enable this for your CDN type.

Browser Cache is enabled

Support us – entirely up to you!

Debug. I use this only when I get an error message while making changes to settings. I’ve only had to use it once and it cleared the error immediately.

Miscellaneous. All options are checked except for Enable File Locking. Note that you’ll need an API key for the Google Page Speed widget.

Import/Export Settings. It’s definitely worth exporting your settings file so you have a backup on your local machine. Click ‘Export configuration’ and save the file locally.

Individual page settings

Page cache settings

General. All options are checked except for ‘Cache URI’s with query string variables’.

Advanced. I’ve left all sections in this category at the default settings. The item most people will want to review is the ‘Never cache the following pages’.

If you’re running a contact form with CAPTCHA you’ll want to add the page it’s on to this section, otherwise your CAPTCHA code won’t change each time the page is loaded.

Cache Preload. All settings are default.

Purge policy. All settings are default.

Minify cache settings

General. ‘Rewrite URL structure’ and ‘Disable minify for logged in users’ are both checked.

Disabling minify for logged in users ensures you’re able to immediately see any changes when you’re making adjustments to design or layout.

Minify error notification is disabled

HTML and XML. HTML minify settings are all checked except ‘Don’t minify feeds’.

Ignored comment stems are left at default.

Java Script. ‘Enable’ and ‘combine only before /body’ are checked. The rest are unchecked.

Adding Java Script files to be minified is best done by clicking the ‘Help’ button above the General section, near the top of the page. This will pop up a window displaying the JS and CSS files on your site that can be minified.

Because some JS files don’t minify well, or minification may stop them from working, it’s best to check one file at a time.

Click the check box next to the file, click ‘Apply and Close’, then click ‘Save all settings’ and preview your site.

If everything is working properly, add another JS file and check your site again.

The other way to add JS files is to view the source of your page and copy the full URL of the file you want to minify. Then click ‘Add a script’ and paste the URL into the box that appears.

Cascading Style Sheets. All items are checked except ‘Combine only’.

Leave @import handling at the default and add CSS files using the same process I described earlier for adding JS files. The CSS files that can be added are displaid below the JS files in the window that pops up when you click the ‘help’ button.

I select ‘All templates’ in the ‘Template’ box, but you may need to select specific templates if you want some to be excluded.

Advanced. I leave all sections in this category at the default settings. If you’re making frequent updates to your site layout or design you may want to reduce the time interval in the first box.

Database cache settings

General. ‘Don’t cache queries for logged in users’ is checked. This ensures you can immediately view any changes you make to design and layout when you’re logged in.

Advanced. All settings are left at default.

Object cache settings

This is disabled on my site so I can’t suggest settings here, I’m afraid.

Browser cache settings

General. All options are checked except ‘Prevent caching of objects after settings change’.

Cascading Style Sheets and Java Script. All options are checked except ‘Prevent caching of objects after settings change’. The expires header lifetime and cache control policy settings are both left at default.

HTML. All options are checked, with expires header lifetime and cache control policy settings left at default

Media and other files. All options are checked except ‘Prevent caching of objects after settings change’. The expires header lifetime and cache control policy settings are both left at default.

User Agent Groups settings

This is enabled by default and mostly defines how to deal with visitors using a mobile device.

Everything is at the default setting here and the only section you need to be concerned with is ‘Redirect users to:’, and then only if a 3rd party site (such as Mippin, for example) is providing the mobile version of your site.

If that is the case you’ll need to add your mobile URL here.

Referrer groups settings

This section is also enabled by default and refers to the search engines or other sites that send large amounts of traffic to your site.

Again, all settings are at the default.

You would create a group and assign a redirect URL only if you wanted traffic from a specific referrer (or group of referrers) to see a different theme.

CDN settings

I don’t have a CDN, so this section is disabled for me. If you do have a CDN you will need to enable it and enter the FTP and other details of your CDN.

After saving your settings

If you enabled ‘Preview’ on the general settings page be sure to check that your site is looking as it should do, and then remember to click ‘Deploy’ to make the settings active on your live site.

I reviewed the first version of W3-Total-Cache that I used here, but it’s changed quite a lot since then.

The thing you’ll notice most on a day to day basis today is that changes you make to your site appear not to show up once you’ve logged out of your admin area.

This is simply because you’re seeing the earlier (cached) version.

So if you want to be sure that you and your visitors see the new version immediately be sure to empty the page and minify caches after making changes to your site.

The plugin will also ask you to empty your page cache whenever you reactivate a plugin.

This mostly happens after plugin upgrades, but if you’re reactivating multiple plugins (for example after a WordPress upgrade) it’s good to leave reactivating W3TC to last.

That’s it – any questions leave a comment.

Cheers,

Martin Malden

Please share this article - I'm counting on you!
       
Found this article useful? Get free updates!

Get regular updates, plus a free eBook on how to set up a business online - join us!

Your details are safe with me.
My Privacy Policy.

Previous post:

Next post: