Speed Up WordPress with W3 Total Cache

Speed up WordPress with W3 Total Cache
If you find this tutorial too difficult to follow, you can hire me to install and configure W3 Total Cache for you.

W3 Total Cache is probably the most useful WordPress plugin you can own (save maybe WordPress SEO by Yoast) and it still baffles me that it is completely free. For the grand price of zero, you get a plugin which will cache your pages, objects, database queries, pair up with a CDN and more. I am still of the opinion that there is not a single WordPress site that could not benefit from installing it.

So with that said, get it installed and then come back here for some guidance on how to set up its myriad of configuration options.

General Settings

When you install and activate the plugin, you’ll get a new icon the menu of the left hand side of your admin area. Click on that icon to bring up the general settings page for the plugin. You’ll want to start here.

Bear in mind that this page is where you “turn on” several of the functions of the plugin and it may be worthwhile keeping them disabled until you have configured the individual components and then returning here at the end to turn everything on.

You may be prompted to allow W3 Total Cache to install lines of code in your .htaccess file upfront and throughout the configuration process. Make sure you have a backup first, and then have it auto-install the code.

W3 Total Cache General Settings 1Page cache

The page cache creates static pages from your dynamic content and serves them up to your users, instead of creating pages on-demand, which massively reduces your server load. You’ll likely find that the only option you have here is to select Disk: Enhanced, which is more than likely adequate for what you need.

If you have a VPS, or Dedicated Server (from Servint for example, my own VPS provider), have them enable Opcode APC on your server and change the caching method for the object cache and database cache to Opcode: APC instead of Disk. This will speed up your load times significantly.

Minify

Minify is the process of removing line breaks, comments and spaces from CSS and HTML files to reduce their size (thus delivering them quicker to the user). Again your only option may be Disk, which it is for me, but that will serve you well. You should be able to select Auto for your Minify Mode and the default settings for all the minifiers unless you have reason to choose something else.

Database cache

W3 Total Cache General Settings 2The database cache saves the results of database queries instead of looking to the database every time the request is made, which significantly reduces the impact on your SQL server. Since WordPress is entirely database driven, nearly every page will make several requests to the database, such as displaying your 10 most recent posts on the front page, or recent comments in your widgets. Use the Disk option.

If you have a VPS or Dedicated server, you might try enabling MySQL’s built-in database caching and turning W3 Total Cache’s database caching off, as it might provide better performance. Test it both ways and see which works better for your particular setup.

Object cache

The object cache stores numerous objects from the database. It may or may not speed up your site, depending on the speed of your disk. You can do a comparison before and after turning it on to see whether there is a reduction in load time and if there isn’t, you might as well leave it turned off. If you are to turn it on however, use the Disk option.

Browser cache

The browser cache works by “telling” your visitors’ browsers how long to keep using the same version of an object. For example, it is unlikely that you will change an image once it has been uploaded, so there is no sense in downloading the image every time a user visits a page – it can just keep the original version and use it over and over again. This will cut a big chunk out of the amount of data needed to download every page, since much of it can be stored on the user’s computer after the first visit. There’s no options here, but you’ll need to enable it here once you’ve set the specific settings in a short while.

CDN

CDN stands for Content Delivery Network, which hosts static parts of your site on servers all over the world so that users can download them from their closest server, instead of potentially requesting it from halfway across the world, reducing latency and load on your server. They’re fairly cheap to use and I recommend it. I personally use Amazon Cloudfront, though there are a number of alternatives supported by W3 Total Cache. I wrote a tutorial detailing how to set up Amazon Cloudfront as your CDN with W3 Total Cache, which will be useful for guiding you through that process.

If you’re interested in a recommendation for a CDN, I’d go with MaxCDN – they’re who I use and their system is easy to setup and amazingly fast. You can sign up for their service here.

Varnish and Cloudflare

You can generally ignore these two sections, unless you know that you have a need for them.

W3 Total Cache General Settings 3Miscellaneous settings

With the miscellaneous settings, I recommend verifying the rewrite rules; I have found that on numerous occasions, other plugins that interfere with .htaccess can mess up the W3 Total Cache settings, so enabling this will tell you when there’s a problem that needs resolving. Else, your site could be running with several parts of the plugin not in effect and you wouldn’t know it.

I also recommend using the Google Page Speed dashboard widget for tracking your page speed.

Also, consider making a donation through the support section. I don’t blame you for wanting to wait to see the results, but if you’re impressed, consider a small donation; support WordPress developers, especially when they work for free.

Page cache settings

Now move on to the page cache settings page. Here is where you set the specific settings for how the page cache should operate. Here’s the settings that I recommend:

W3 Total Cache Page Cache Settings 1General

Enable caching of the home page, SSL requests and requests only for your domain. Also check the box to disable caching pages for logged-in users. I don’t recommend caching feeds because if you make changes, you want it be reflected in your RSS feed, which I have had issues with before, when I had this option enabled. I also don’t recommend caching 404 pages because they shouldn’t be used very often and they will return an error code of 200 (OK) rather than 404 (not found), which is undesirable, so they’re not worth caching.

Advanced

For most users, you won’t really need to touch the Advanced settings, but you can reduce the Garbage Collection Time, which is how long the cache holds a version of a page before building a new one (the default 3600 seconds – 1 hour should be sufficient). You can also set specific user agents (like bots) that shouldn’t be served pages from the cache, or set specific files which should never be included in the cache.

W3 Total Cache Page Cache Settings 2Cache preload

These options allow the cache to be pre-built (i.e. it builds the pages in the background rather than waiting for someone to view a page and build it on-the-fly. This helps to spread your server load more evenly and reduces load times for those who are trying to view a page that hasn’t yet been viewed, or has expired in the cache. I use an interval of 600 seconds and build 10 pages at a time. You’ll need to adjust this based on your server and the number of pages on your site. If you have 1000 pages and you’re only building 10 every 10 minutes and your cache expires every hour, then you’ll only be able to build 60 out of your 1000 pages before it needs to start over again. Be sure to insert your sitemap address and enable to the preload function.

W3 Total Cache Page Cache Settings 3Purge policy

The purge policy dictates which pages should be rebuilt in the cache when a new post is published. For example, your front page likely has a list of your most recent posts, but if you don’t purge it from the cache when you publish the post, it won’t show on the front page until the cached page expires and it gets rebuilt with the new information (your new post). For me, I purge the home page, post page and blog feed (all feed types). The other pages are so infrequently used that it wouldn’t really matter if they have slightly outdated information – this might not be the case for busier sites.

W3 Total Cache General Minify SettingsMinify settings

In the General section, enable the Rewrite option and disable minify for logged-in users. Also set how you want to notified if there’s a problem with minifying your code.

HTML & XML

I recommend enabling all aspects of HTML minifying. This includes leaving the box for not minifying feeds unchecked (so that feeds get minified too).

JS

Some people report issues with minifying Javascript, so use this with caution. I’ve enabled it and it doesn’t appear to cause issues with my site. All you need to do is check the box to enable it; you can leave the other five options unchecked, unless you only want to combine Javascript files that appear within certain portions of the page (such as the header, or footer).

W3 Total Cache CSS Minify SettingsCSS

For the CSS section, you want to be sure to set it up as I’ve shown in the image, by prcoessing @import files (these are files that are imported into other CSS files by using the @import function – we want to minify those as well) and removing comments and line breaks. Leave Combine only unchecked, because we want to take it further than just combining the CSS files (we want to minify them as well).

Advanced settings

Again, you don’t need to fiddle around too much with this. You can fiddle with the garbage collection time if you want something more or less frequent than the default 86400 seconds (1 day) or specify rejected user agents or pages that shouldn’t be minified.

Database cache settings

In the general section, make sure that the option to not cache queries for logged-in users is checked. You want to be sure to have the latest version of your site every time it’s loaded.

Advanced

Again, there’s not too much to fiddle with here unless you have good reason to. As with other caches, you can set garbage collection times, expiration times and pages that shouldn’t be cached.

Object cache settings

As I mentioned earlier, it’s debatable whether this will even do you any good, but if you do enable it, you can pretty much leave the default settings as is. Not much else to say on that one!

W3 Total Cache Browser Cache General Settings

Browser cache settings

This section is a bit more important and involved. It tells visitors’ browsers how long to hold on to files it downloads. Here’s how I recommend setting it up:

General

Essentially, you want to ensure that you set every option for including information in the page header. However, you can leave the options for preventing caching objects after changing settings and not letting WordPress process 404s. It should look like it does in the image to the right.

CSS & JS, HTML & XML, Media & Other Files

W3 Total Cache Browser Cache Specific Settings

All of these sections will essentially look exactly the same, making use of all the header information available. The only thing you’ll want to change is the expiration time in each section. I would set the expiration time for CSS and JS to 2,628,000 seconds (1 month), HTML and XML to 3600 seconds (1 hour) and Media & Other Files to 31,536,000 seconds (1 year). You can adjust these based on how frequently you think these types of files are likely to change on your own site.

CDN

The Content Delivery Network section will depend on your specific CDN provider, but I have already created a separate tutorial for setting up W3 Total Cache with a CDN (Amazon Cloudfront in the example). Regardless of your provider though, the long and short of it is that you want to serve as much static content as possible from your CDN rather than your own server.

Once you set up your CDN (if you’re going to use one), you can head back to the General Settings page and enable all the components that you’re going to use. Then log out (since some components have purposely been disabled if you’re logged in) and browse your site. It should be immediately apparent how much faster your site is, but you can also perform some tests using Pingdom Tools, which is very useful for showing your page load speed.

So, did you get it set up successfully? What settings did you tweak and why? Are you having any issues? Let me know in the comments!

120 thoughts on “Speed Up WordPress with W3 Total Cache”

  1. Paul Salmon says:

    Great tutorial! I have been using W3 Total Cache for some time have have had no issues using it. I love the fact that much of the caching is managed without having to resort to editing the .htaccess file.

    I am currently using CloudFlare withe W3 Total Cache without any problems. I like the fact that when I make a change, I can clear the CloudFlare cache directly from W3 Total Cache.

    1. Hi Paul,

      Thanks very much. W3 Total Cache works pretty well out of the box, but I see that a lot of people are (understandably) are a little confused about all of the options. I have been using it for a year or two and can’t do without it now.

      I’ve shied away from Cloudflare though; I’ve heard some not so good things about it. How do you like it and what does it do that other plugins/services can’t do?

  2. Cindy says:

    I haven’t heard about this plugin yet. Is it really worth to install it? I don’t have speed problems on my site, but I heard so much of the benefits of the CDN. Any suggestions?

    1. I’d absolutely recommend installing. It’s just one of two plugins that I install on every single site I do. The caching functionality of the plugin is reason enough to install it, but the extras, like the CDN for example, are well worth it. Go and install it now :)

  3. Dave, wanted to thank you for this detailed tutorial. I have been waiting for this article to set up W3 Total Cache. Ran into a little hiccup, the the plugin’s directions are so good, I was able to fix it myself.

    1. What was the hiccup? It’d be good to know – if we post it here, others who encountered it might be able to resolve it. Glad it generally went well for you though.

      1. Hiccup 1. Supercache had apparently usurped the /public_html/wp-content/advanced-cache.php file. I created a new “advanced-cache.php”. Then W3 Total Cache used it to add some code beginning with the title ” W3 Total Cache advanced cache module.” Page caching started working.
        Another hiccup. CommentLuv stopped working. I disabled JS under the Minify menu. Works fine now. Don’t know how much speed I’ll lose from not minifying JS . . .
        Third hiccup, I just figured out. I had Enable Google Page Speed dashboard widget enabled (under General for W3). Well, that turned off the JetPack admin bar, including 48 site stats and even the W3 “Performance” bar itself. They all came back when I disabled the Google Page Speed widget. (I haven’t completed the API page speed key for the Google cloud sign-up because I don’t understand it. I did just sign up for AdSense and Page Speed API service and will experiment.)
        W3 Total Cache is more complicated, but seems promising!

        1. Yes, WP Super Cache must be deactivated first, as the two will conflict with one another. It is a little more complex to set up, but once you’re there, it does so much better than WP Super Cache. I hadn’t heard of these other conflicts, but it’s good to know. Thanks for the follow up.

          1. Further follow-up. Following the simple directions on W3 Total Cache, I got my Google API page speed report API code for the W3TC page speed widget (shows up in the *dashboard*). Works great, doesn’t turn off the JetPack tool bar. My page speed is pretty good, 91. The speed fixes Google suggests, Reduce request serialization and Defer parsing of JavaScript, all point to AdSense and Amazon widgets, so there’s not much I can do (unless I remove those).

          2. Well and there will always be ways to speed up your site – you can always remove things, but it’s about drawing a connection between site functionality and speed. It’s no good having a fast site if its bare bones and doesn’t do what you need it to do. So, striving for 100 is not necessarily a good idea.

  4. james says:

    very interesting
    is this for all browsers?

    would be good to try this out
    thanks heaps :)
    james

    1. Yes, provided that the browser supports caching, which all major browsers do, then the results will be seen by users of all browsers.

  5. Richard says:

    Awesome tutorial. w3 total cache has so many options that it can be a bit daunting to set up. I like it a lot as i’ve got it set up with cloudflare as well. I like that it supports cloudflare natively. Once it’s set up properly, I get a great boost in speed. The only thing is to be careful about running any other caching plugins as you can run into conflicts and sometimes cause drastic slowdowns on your site

  6. I used W3 Total Cache for months, and it is very good, but then decided to change to Super Cache… why? I think that Total Cache uses more resources.

    So, if you have a fast server, Total Cache can be the best option, but Super Cache is better if you don’t have a quad core.

    1. That’s interesting. Just last week I used a plugin called P3, which tests how many resources each plugins uses and W3 Total Cache was way down on the list. I’d encourage you to use this plugin to compare both plugins. I left WP Super Cache behind a long time ago.

  7. Neil says:

    Hi, thanks for the installation tips! I installed according to your instructions and my site grade in YSlow went from a D to a B. So far, so good. However, when I test it on all my browsers, I do the following to see if there are any nasty surprises. First, I go into W3TC and empty all the caches. Then I open my internet browsers and empty those caches. Then I visit my page and sometimes it comes up very plain, basically without all the graphics – just like a very simple html page. Then when I refresh it, it loads as it should. Do you know what this is about? I want to make sure that first-time visitors to my site won’t see it load that way. Thanks!

    1. Well the problem you’re describing is that the CSS isn’t loading (maybe its minified and there’s a problem with the way it’s configured). To make sure everything is working right, empty your W3TC caches, log out, clear your browser cache and then visit the site. That should give you a good idea on how new people will see your site.

      1. Neil says:

        Any chance you could visit mycampaignpage.com and let me know how it loads on your end? I’m testing here and get mixed results. Also, is it possible to “un-minify” my css if this is an issue or do i need to reload an “un-minified” version?

        1. Looks perfectly normal to me. Loading well. If you need though, you can turn off Minify from the General W3TC Settings page

          1. Neil says:

            Thanks Dave! Last question – In case I ever have to turn off Minify, will my css sheets go back to their original form or is it already “minified” and they can’t be reverted once the minify function has taken effect?

          2. No, if you turn off minify, it will just resort to using your original stylesheets – it won’t try and use the old minified sheets.

  8. Neil says:

    Hi Dave,

    I’m back! I’m stumped on an issue and I hope you might have some helpful tips. My sites are now loading really well and I think I just about have the W3TC settings figured out. But what is strange is that they’ll load really fast with a cleared internet browser cache. Until after about an hour, again with a clear internet browser cache, they don’t load quickly at all. Then the next visit, they load fast again. And then repeat! (FYI, I check my sites continuously since I’m trying to nail down these settings).

    What I’m wondering is if my cache settings are tossing out the cached pages on a set interval and they are re-caching during my subsequent site visit.

    If my diagnosis is correct, what setting can I change to lengthen this interval? As a fyi, my site content really doesn’t change at all. I just market a service. Therefore I don’t need the site to automatically purge cached pages often, if that makes sense. It’s not like a news site or a blog.

    What would happen if I change my browser cache html expires header from 3600 to maybe 86400? Or should I be looking at something other than the browser cache? Do I need to change the garbage collection interval?

    Thanks Dave!

    Neil

    1. Hi Neil,

      I believe the very last sentence in your comment is what you’re looking for. The garbage collection interval sets how long a cached page is good for before it bins it and creates a new one. The longer that period, the less frequently that cached pages will need to be built, however that’s at the expense of not keeping your site as up-to-date (changes won’t go live for longer). Your browser cache settings (HTML) may also be to blame – you’ll have to experiment with different values to see what works best for your site (based on traffic volume and frequency of updates).

      Hope this helps

      1. Neil says:

        Thanks Dave!

        I’m going to play around with the values on the browser cache html expires header as well as the garbage collection interval. Under garbage collection interval, it says to set it for how often “expired” cache data is removed. I’m curious if that means it won’t remove the cached page unless it’s actually expired. So if I set my cached pages to last for 1 day (since I rarely have site changes) and the garbage collection interval remains at one hour, it won’t actually purge the cached page until after it has expired.

        As you said, I will continue to experiment with different values to see how it affects loading time.

        Thanks, as always, for your advice.

  9. Cari says:

    Hi there–what about multi-site installation? I’m a total beginner and I’m scared of breaking everything. Do I install that htaccess on each site or just the main site? Do I activate wtc in each site and then make the settings identical?
    Thanks!

    1. With Multisite, there is only a single .htaccess file, since there are no different directories for each site, so you need to make all the modifications to the single .htaccess file. Just make sure you take a backup first and you’ll be fine.

      1. Cari Taylor says:

        What about the settings within each site? I activated the plugin in each site, and exported, then imported the settings from the main site into the ‘kids’ w3tc settings, but it didn’t actually duplicate the settings. grr.

        1. Hmmm, not sure. There’s also an option if you go into the Network Admin to have new sites copy their settings from an existing site, which I’ve used and works well. Not sure what’s going on with the export/import feature though.

  10. Brian says:

    I totally agree with Yoast SEO being the most useful plugin. I have definitely been a fan of Joost’s for a long time. For this cache plugin, I know it would be helpful on a image rich website, but what about a normal blog. I’ve always been afraid of messing with htaccess and I’ve messed up by not backing up like I should. If there is an easy backup plugin, I may need to get that first and then try this one.

    1. I recommend Updraft and/or WP-DB-Backup for keeping your site backed up automatically. The main benefit of caching is in reducing WordPress’ queries to the database, which doesn’t much matter whether it’s image rich or not, so it will be useful for any site type. Be sure to take a backup of .htaccess before you modify it (standard editing practice).

  11. Tom says:

    I’ve just added it to my website, but apart from just refreshing pages myself, is there any way to get a quantitative figure on the improvement since installing it?

    Thanks

    1. Yes, you could use a tool like http://tools.pingdom.com, which I use to measure my page speed and performance.

  12. deep says:

    Hey Dave, is this plugin better than the WP Super Cache ? I am presently using it in my blogs.

    1. I personally think so. It does a whole lot more than WP Super Cache and performs much better. I used to use WP Super Cache too, but I’ve been converted to W3 Total Cache.

  13. Dave West says:

    Hi Dave, Thanks for the GREAT post. I have a newbie question.
    How do you know for sure that the plug-in is working properly? The following message is always toward the top of the screen:
    Preview mode is active: Changed settings will not take effect until preview mode is deploy or disable. Preview any changed settings (without deploying), or make additional changes.

    When I press “deploy” under general settings I get a clear screen with the following message:
    “Are you sure you want to do this?” – Please try again. (and the page tab says: WordPress Failure Notice).

    Yet there is a line in the upper part of the general settings page that says: The plugin is currently enabled. If an option is disabled it means that either your current installation is not compatible or software installation is required.

    BTW: plugin version is 0.9.2.4 running on WordPress 3.3.1 Thanks in advance for you help.

    1. Hi Dave,

      On the General Settings page, you should be able to click on the Disable button for Preview Mode and that message should go away.

      Let me know how it goes.

      1. Hi Dave,
        I have the same message error, I click on the disable button for preview mode and doesn’t works. Also say:
        File and directory creation tests failed
        Could not mkdir: \\WAGNER\wwwrootnom$\9da1529b9.hostnd\htdocs\www/wp-content/cache\test_dir
        Help?
        Maybe hosting problems?
        Super slow place… but no reasons!!

        thanks thanks great post!!!

        1. If the plugin is having trouble making directories, it sounds like a hosting issue.

  14. devesh says:

    Hey Dave I have downloaded the W3 cache and installed it but after editing the setting when I try and save it removes all changes made and reloads the default setting. Is it any other plugin that creating the problem or what? please help.

    1. Devesh, I’m not sure what’s creating the conflict, but I have not observed these issues. It could well be another plugin or a particular facet of your individual site set-up, but I couldn’t guess at what that might be.

  15. Hi Dave! I just set up the plugin exactly like your tutorial (ezcwpt under the minify tab, I only have jss enabled, but didn’t check any of the subcategories for it), and on some pages, my main content doesn’t show in some browsers. It appears to be fine in my blog, but I’m also using the shopp plugin. If I go to a product page, the center column that has the info is blank. It seems ok in firefox, but not in Safari, opera, or chrome. I also have Shopp Cache helper installed, but I noticed this issue before I installed it.
    To get everything to show up, I had to uncheck everything in the HTML & XML section under the minify tab. When I test the speed at pingdom.com, there’s not much difference between when the plugin is activated & when it’s not (says areoun 89% of all tested sites are faster than mine). I don’t have CDN activated because I don’t have those services. Do you have any suggestions on what I can do to speed things up & still have all of my content show up?

    Here’s a link to check it out:
    http://www.tracibunkers.com/blog/shop/asian-intrigue-rubber-stamp-sheet

    Thanks,
    Traci Bunkers

    1. Hi Traci,

      I’m not sure what the Shopp Cache plugin is, but it sounds like that might be in conflict with W3 Total Cache. Also on reviewing the speed test of the URL you left in the comment, it seems that it takes almost two seconds to just connect to your server, which is a big chunk of your page load time. Furthermore, the server is taking a long time to connect and load the large number of images (shown by the blue portion of each bar), rather than the time to actually get the image data (yellow and green parts). I would think that a CDN will help enormously in churning out those images a lot faster. Do a page speed test on my front page (http://www.doitwithwp.com) for example and see how quickly all the images are loaded from my CDN.

      Hope this helps.

      1. Hi Dave, Thanks for getting back to me. Although I could be wrong, I don’t think the Shopp helper cache is the culprit–I didn’t see any difference in speed without out. Without the plugin, there are issues in Shopp using W3Total Cache–I’ve read if 2 customers are shopping, 1 person can add something to their cart & it will also show up in the other person’s cart also. From what I read, this is common for any caching plugin.

        I’ll look into CDN. Do you think the slowness I’m experiencing is an issue with my webhost? How exactly can I tell if it’s something I can tweak, or something that’s y host’s issue?

      2. I set up the CDN with Amazon Cloudfront (following your excellent tutorial), but I’m not sure it helped much with speed. When I use the pingdom tools, I still get a message that my site (http://www.tracibunkers.com/blog) is 87% slower than others tested. But that can really vary anywhere from that, to my site is 47% faster–all testing the main page on my blog. When I test it with the Google Page Speed report, I always get a 79/100.

        1. Well, i had a look over your blog and it seems that a large number of your images have two problems: 1. they are oversized (e.g. showing a 2000×1300 pixel image in a space that’s only 300×200 pixels). 2. They are served from external resources, which means that they won’t be sent through your CDN. In order to serve them up from your CDN (and not from Blogspot, Flickr etc.), they need to be in your Media Library.

          1. Oh, yes, I put my photos for my blog on flickr–when I started doing that years ago, I thought I was being smart by not using up my own disk space. But I guess it’s not in the long run. Do you suggest switching them all over–going back through all of my blog posts & redoing the photos? Or from now on not put them on flickr & put them in my media library instead.

            How can I figure out which photo was that large? That was a mistake. I know some are resized, but usually only by a small amount. IN looking through the testing things, I remember seeing which photos were resized, but now I can’t remember where I saw that. Thanks for your help!

  16. Shinjo says:

    Hi Dave, thanks for writing this great tutorial. I’m currently trying to implement it for my site but seems I’m having trouble with minify. When minify is enabled my site couldn’t display styling at all, it only display plain html without styling. Do you have any idea why this happen? and how to solve it Dave? I’d still like to have minified css rather than turn it off completely. My site is pasargame.org please visit it if you have time and tell me what should I do. Thank you bro

    1. Yes, minify has been a bit hit and miss for me as well. On some sites it’s worked and on others, it’s screwed up my styling. It doesn’t make a massive difference in speed, so it’s not a huge deal if you can’t get it working.

  17. Andrew says:

    Thanks for your guide. OK, probable daft question here. As a shared hosted user (Easyspace) I take it that caching is not just browser caching but also server caching. In either case surely the first time a page is viewed by someone the subsequent re-viewing cached benefit is not gained? Have I misunderstood the difference between server and browser cacheing?

    1. Andrew,

      I don’t believe so. You can set your database cache and browser cache to work at different intervals. When a page is first viewed, it will be created and stored in the page cache. It will either pull new information from the database, or if there is applicable and unexpired database information in the cache, it will pull it from there instead.

  18. Bill says:

    Great article, it sure was daunting to look at W3 for the first time!

    Quick question on some advice… I am running bbPress forums in the mix. Those are pages I wouldn’t want cached much if it all (but in using it while they are, it sure is fast!) What’s the recommendation around that, to not cache the forums?

    But a potentially bigger issue is with logged in users. Since all forum users are “logged in”, they don’t benefit from any other site caching :(

    Any thoughts appreciated sir!

    1. I’m not sure of the URL structure of your BBpress pages, but you can use the exclusions area to make that those pages aren’t cached. As for logged-in users, you could turn that off, and then if you make any changes that you want to see, you can flush the cache.

  19. Sarah says:

    Hey Dave I follow your settings but I still have these issues

    Leverage browser caching, Enable compression, Combine images into CSS sprites

    I have a Score of 55 on google page speed test & 58 on my dashboard.

    Can you help me please. Thx

    1. Are those “modules” enabled on the General Settings page, and then again on the individual tabs? Combining images into CSS sprites can’t be helped by W3 Total Cache, but browser caching and compression should be helped by the Page Cache part.

      1. Sarah says:

        Thx dave. My score is currently 70-80. I went to empty the cache after following your settings LOL. Can you explain more about CSS sprites and is it necessary to make the changes suggested ? Thanks!

        1. CSS sprites are essentially multiple images merged into a single image. It will help your site load time, but it’s by no means necessary. These are just recommendations. CSS sprites are one of the recommendations on my sites, but I still haven’t done it.

  20. The Dude says:

    Using w3 total cache with the said settings did took the yslow score up by 6 points. But i still get an error about external javascript files not being combined in a single file. So make fewer html requests is still an F and i haven’t been able to find a workaround with hours of searching. Can you please guide me how to do that? Other than that, the tips have worked wonders :) Thanks for great tutorial.

    1. Make sure you turn on Minify for JS to combine all of the files into one.

      1. Dave,
        I read here, http://richwp.com/wordpress-cdn-total-cache-amazon-cloudfront/, that if the site uses jQuery, that minifying JS can cause an issue. Have you seen this as an issue? My YSlow grade even with CloudFront CDN and W3 Total Cache is a D. Clearly I have some things to work out. What’s interesting is that “best practices” says you should have at a minimum 8 CNAMEs for CloudFront however the YSlow rule argues that I need to reduce DNS lookups. Also, I see some other items like Add Expires headers which I would expect W3TC to add as a function of browser caching. As I said, I have a lot to look into. Thanks!

        1. I have. On most sites, I can’t minify JS and I believe that jQuery is the reason, but I don’t know enough about Javascript to tell you why. I’ve gone back and forth on the CNAMEs. I am currently working with a single CNAME using MaxCDN and it works extremely quickly, so perhaps multiple CNAMEs aren’t needed after all. Seems that it’s a contentious issue.

  21. nikhil says:

    Is it necessary to use WP minify along with W3 total cache?

    1. No, W3 Total Cache uses its own minify function

  22. ahmet canbey says:

    Thank you for you have given expression. You mentioned really nice. I could not do a thing. google pagespeed report appeared the following results. Take advantage of browser caching, Suggestions for this page

    The following can be cached resources with the new dating life is short. Current sources provide at least a week after the expiration date:
    http://www.bilgisayarix.com/…/li-bg.png (end time specified)
    http://pagead2.googlesyndication.com/pagead/osd.js (60 minutes)
    http://pagead2.googlesyndication.com/pagead/show_ads.js (60 minutes)
    http://www.google-analytics.com/ga.js (12 hours)

    How do I fix this section of the manual method. Thank you in advance for your interest.

    1. You’ll have to live with some of those, since they’re external files with their own cache times, set by their owners. I’m in the same boat. I can’t cache my BuySellAds ads, so it just throws up a red flag in my speed tests, but it’s not that big of an impact; you’re only looking at four files, which is pretty minimal.

      1. I’m in the same boat with BSA, is it possible to set a “defer” on them to improve page load time? BSA is loading 1.1MB for each pageload and it’s killing my overall speed.

  23. john o'grady says:

    Hello Dave,
    thanks for the guide, it’s really useful. I have a photocrati site and on Minify auto it stops me using the lightbox facility. I’ve tried using minify manually with some success but then my site crashed. I have gone back to using Auto minify. Can you recommend any lightbox or fancybox that might work without having to disable minify?

    thanks in advance
    john

    1. John, I’m not aware of any that won’t cause an issue; it’s a case of trial and error. However, you could just turn off JS minify (I’m assuming that’s the issue), or check the theme files and see whether they’re loading a different version of jQuery than WordPress does, which could cause an issue.

  24. Fantastic post Dave. After following your tutorials above, I was able to increase my Page Speed Grade at GTmetrix from 74% all the way to 88% and YSlow grade from 64% to 77%.

    My only problem for now are Defer parsing of JavaScript, Specify image dimensions, Combine images using CSS sprites and Use efficient CSS selectors because all of these needs attention as they show all at F (0).

    And Remove unused CSS is E. The rest all “GREEN”. So any suggestions how to improve those F’s above Dave?

    Using pingdom tools my loadtime is 5.13 seconds with http://sonnylanorias.com/blog while for http://sonnylanorias.com the loadtime is a horrible 60 second :(

    So any help from you will be highly appreciated Dave. Thanks again for this EXPLOSIVE post and hope to hear from you.

    =>Sonny

    1. There could be several reasons for those errors. Parsing of Javascript is dependent on when your theme loads it. It should be loaded in the footer as much as possible, but your theme might be loading it in the header. Image dimensions – if there are hard-coded images, your theme might not be specifying the dimensions as they should. CSS sprites is a bit more of a technical venture and you’d need to research that if you want to do that (it says that for me, but I’ve never gone through the hassle). Efficient CSS selectors is also your theme and how they’ve laid out their pages and the CSS for it. Unused CSS means that there’s a whole load of rules in your CSS files that you don’t use that could be removed.

      Are you using a CDN? If not, that would be my next move. If you’re loading image-intensive pages, all from within WordPress, that will slow things down. Delivering them a CDN will speed it right up.

      Of course, remember that your aim should not be to score 100%. That would be an absolutely perfect site, but is not right for every site. My site is currently at 88/100 with Google Page Speed Score. Not the best, but pretty good.

      1. Okay thanks Dave. Maybe changing to DIYtheme will help? What do you think? Or just edit my theme codes? Thanks

        1. If you feel confident, you can always try and edit your own theme (back it up first). Or try and look for a more efficient theme. I personally don’t like Thesis (DIY Themes), I think it’s very bloated as well. A better alternative is Genesis.

  25. By the way Dave,

    Just a side note, why is it that after I published a new post, the latest post didn’t show up on my blog page? Before it was showing without any clearing my caches and cookies. So I guess it was something to do with the setup that I just made in my W3 Total Cache or maybe missed something. Let me know and thanks again for this powerful post. 5 STARS to you Dave!

    =>Sonny

    1. It could be that your browser is pulling the page from your own cache. W3 Total Cache should automatically clear the cache when you publish a new post (assuming you haven’t disabled that option).

      1. Okay great! Thanks again Dave. You rock.

        =>Sonny

  26. John Turner says:

    Best Guide I’ve found so far for W3 Total Cache. Kinda surprised those guys don’t have these types of details within the plugin, but makes this post even more valuable. I thought setup for this was gonna take hours, but with this guide it took maybe 30 minutes, if you include all the double and triple checking.

    Even was able to point a few clients towards this post as a handy way to setup W3 Total Cache, cause otherwise they would do what I might have done without this: just left it on the defaults and hoped it was helping.

    Seriously, massive knowledge!

  27. Ian D says:

    Firstly an awesome tutorial on W3 Super Cache. So the results??

    Started off:

    79 / 100 at pingdom 3.42 seconds to load

    Google insights 72 / 100

    ——— ———— ———– ———— ———-

    Finished 92 / 100 and 1.66s

    Google insights Google 75 /100

    So up on both and good results all round?

    Not quite because it brings the admin side of the site to its knees and makes it unworkable. I wasn’t happy at all with that. Turn it off and I’m back to where I started. Was it worth the 2 hours of tinkering? Possibly but its having a poor effect on the rear end and I’m not convinced its a better result as of yet.

    Good article though!

    1. That’s interesting. I’ve never heard of W3TC having a negative impact on the admin. That’s most bizarre. I’d be intrigued to hear about it if you ever look into this more. Thanks

  28. I’ve been having a nightmare with my images not browser caching (max-age=14400).

    If Anyones having a similar issueadding this to .htaccess works.

    RewriteEngine On
    # Set the cache-control max-age
    # 1 year

    Header set Cache-Control “max-age=31449600, public”

    # 2 DAYS

    Header set Cache-Control “max-age=172800, public, must-revalidate”

    # 4 HOURS

    Header set Cache-Control “max-age=14400, must-revalidate”

    But I’m not entirely happy about this ‘hack’, doesnt feel right to me but gets me upto 90/100 rather than 82/100.

    The ‘ExpiresByType image/jpg A31536000′ parts just don’t seem to work??

    1. Why would you have such a short life on images? Do you update image files that frequently? I would think that a year would be more than enough. I’ve never encountered this issue and my images cache fine.

      1. I do want to set my images for 1 year. Total cache is setting my .htaccess correctly too (ExpiresByType image/jpg A31536000) etc…

        Browers are only reading it still as 14400 annoyingly.

        It’s weird and annoying, adding the below to my .htaccess did do the trick though.

        ***
        Header set Cache-Control “max-age=31449600, public”***

        Cheers for the post btw, I went through it completely and my site is a tonne faster!

  29. Sorry every time I paste the code above a part of it disappears.

    FilesMatch “\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$”
    Header set Cache-Control “max-age=31449600, public”

  30. Ian D says:

    Sorry bit lost here.

    How and where do I set it to cache my images for a year? Having the same issue with Google Insights.

    ta muchly,

    1. Under the Browser Cache settings, you can set the time in seconds for the Expires Header for Media & Other files, which would include images. One year is 31,536,000 seconds.

  31. W3 is such a great tool. One of the most important plugins I’ve ever come across. I use it on every website I launch, and it’s just fantastic to get those 90+ scores in Google Page speed.

    On top of that, it’s nice to see the plugin developer is still active and that he keeps adding cool features like separate caching for desktop computers and smartphones.

  32. DARRYL says:

    I too use Servint, and contacted them about enabling Optcode APC as you suggest. They said eAccelerator has been installed on my server, and performs an identical function to APC, and tends to be more compatible with their infrastructure. They said they could enable Optcode and uninstall eAccelerator.
    Do you have an opinion on that, and would Optcode be better?

    1. Honestly, I don’t know enough about these different technologies to tell you which one is superior and under what circumstances, but Opcode seems to generally be the preferred option, and I’m surprised that Servint told you their setups are more conducive to eAccelerator. Nonetheless, I don’t have experience with either eAccelerator or Memcached to give a valued opinion. Anyone else, feel free to jump in and discuss…

  33. Darryl says:

    Also, what is your opinion on selecting Memcached?

  34. Recently, I’ve noticed if you click on a link to page on my blog, the URLs have numbers after them, like this:
    https://www.tracibunkers.com/blog/#.UKqCr-1alOc

    That didn’t used to happen. I’m not sure if it’s due to something I’ve changed in W3 TC with caching, or what. If you refresh the page, the numbers are different. Do you know what’s causing this? Is it something I should be concerned about?

    Thanks!

    1. Yes, I’ve never seen that before – that’s quite odd and isn’t something that W3TC should be doing. Are you using Cloudflare at all?

      1. No, I’m not using cloudflare. Just Amazon cloudfront, and also S3 for backing up.

        I wonder how I can figure out what is causing this. I recently moved to a new host, but if that were the cause, then it would have happened right when I moved–which it didn’t.

        1. Yes, it would have. Ultimately, I wouldn’t be too concerned. Your score is fairly high, and it’s not always possible to achieve 100, because of the functionality we include on our sites. My site runs at a 91, so still not perfect, but pretty good.

      2. Thanks to google, I found out it was the AddThis plugin causing it. I had recently changed some setting on it–and under the advanced settings, activated “Have AddThis track address bar shares”. I unchecked it, and that solved it.

  35. Jonas says:

    Hello,

    I’m also hosted with ServInt and I’ve set up W3TC at the moment correctly, but I have one question. What do you use for “Default lifetime of cache objects” in the database and object caching sections? It defaults to 180 seconds, but isn’t this too low? I’d love your suggestion on this matter. (APC is also enabled by ServInt).

    Kind regards,
    Jonas.

    1. Nope, my database and object caches are set to 180 seconds and are doing just fine. You don’t want to cache database information for too long.

  36. Vincent says:

    Thank you for your wonderful guide! It helped my site a lot. I followed your instruction but my Combine external JavaScript grade is 0! I have tried enabling/ disabling the JS in the minify settings and there were not much difference. I hope you can help me.

  37. Diandra Fernandes says:

    Hi Dave,

    Thanks for this tutorial. It was super. But how do I deal with this plugin after the set up? I mean, when do I have to empty all caches, for instance? And to make some changes in my blog theme-wise and in the widget area how should I proceed?

    Best regards.

    1. Once it’s set up, you can leave it alone. There’s no need to do anything manual at all. If you activate or deactivate a plugin, you’ll get a notice, recommending that you empty the cache so that the plugin’s effect on page content can be seen, but other than that, you can set it and leave it.

    2. I’ve found it handy to disable the minify’s when making changes to the design, so I can see the correct line numbers when editing CSS in my browser.

      1. That’s an option, or you can just make sure that Minify is turned off for logged-in users ;)

  38. Mike Keating says:

    Thanks for the post. I’ve been browsing the web looking for set up guides for this plugin and found yours one of the better of the bunch :) Just as a heads up, if you decide to delete this plugin, do so accordingly. If not, you may encounter infinite loops and other errors that were difficult to fix for people unfamiliar with servers and other more technical aspects.

  39. Awesome and thank you for the post. Already a huge improvement, I saw you have another post for Cloudfront……I’m going to look into that now.

    I also noticed a section in W3TC for Cloudflare, can that be used in conjunction with cloudfront? And if so would that help?

    Thanks again for this.

    1. Cloudflare is a collection of tools, including a CDN, so there’s no real sense in using Cloudfront if you’re going to use Cloudflare, because you’ll already have a CDN in place

  40. Yes, using the manual minify method, you can specify when each JS file should be loaded, so you can load BSA at the very end.

  41. Lola says:

    Hi Dave,

    You had the best tutorial for w3 tc that I found around. Thanks.
    I am confused about one thing though. When I do some changes on the pluggins settings, do I have to empty all the caches or empty the cache for that setting or this not necessary? Because recently I disabled my Minify features but that is still marked as something it is done on my developers page insight. So, that is why I am confused.

    Best regards,

    Lola

    1. Well, when you change your settings, emptying your cache is wise because otherwise the pages in your cache will have been created using the old settings. In some instances that might not be a problem, but if you disabled minify because it was causing a problem, you’ll definitely want to rebuild your cache when you disable it.

      1. Lola says:

        Thank you very much for your reply. I could not find information on how to use the plugin in daily basis. And I really do not know if I am using it right. Actually that would be a good theme for a post, I think. Thanks again, man.

  42. Abi says:

    Hi Dave,

    What is the difference between disk enhanced and basic? I have disk enhanced on but someone once said that might not be good for who displays ads. Is that true? Can it cause any other problems? Which one is the best?

    1. Disk Enhanced is better, but may not be compatible with all hosting environments. I’m actually not sure of the technical differences, but if it works on your site, you should select Disk Enhanced.

  43. Ramanan says:

    Fantastic tutorials Dave – this and the one with Cloudfront. Starting with zero knowledge about these things, I was able to do put everything except the html on Cloudfront and really improve the response of my blog on a shared server.

    Thanks so much – I used your two posts highly.

    So: CSS and JS minified and put on Cloudfront. Also images.

    One extra advantage of minification using W3TC – which seems to be less highlighted – is that it changes the filenames and so one doesn’t need query parameters in URL strings. So one can set the expiry as long as one wants without worrying about regular viewers’ cache as anyhow the filename of the css (such as of the layout) will change if you make changes. (Although I think there are small bugs in w3tc minify). Plus of course, W3TC minify also controls how the scripts are loaded – after the body/asynchronous etc.

    I have issues with feeds and w3tc so I have not used it.

    I am trying to understand the html part of w3tc – if I am not wrong, the disk enhanced method makes html files – zipped and unzipped in the cache folder and redirects the visitor to these files.

    I am still experimenting html caching. Have a few questions. If I set the expiry to x it is taken as the TTL as the footnote in page cache says. However, do I need to tick the check box above it for this to happen? The reason is that I choose no-store, no-cache in browser settings and want to make sure browsers don’t treat expires superior to no-cache.

    One place where I have seen issues with browsers – especially Chrome – is that suppose I choose expires as 3600 for HTML and choose cache with max-age=expires and validation, Chrome simply ignores this and checks only after 3600s. Safari doesn’t seem to do it and if I make a change in a post, it catches it immediately.

    Congratulations on your new born – very sweet looking.

  44. zafado says:

    Hi:
    definitely this is the best tutorial for W3 Total Cache, helped me with my websites, have improved their speed.

    Lately this plugin has been updates with new features, please could you update your guide to the latest changes of this plugin, of course if you have some free time.

    Thank you very much for all the information.

  45. Sara says:

    Thank you for this detailed post! Very much appreciated!

    One question, I followed these instructions and everything seems to be working properly but now only the top part of my background image is loading. Do you know why?

    Thanks!

    1. No reason that it shouldn’t unless there’s a specific rule that’s preventing it.

  46. arroway says:

    I have a question: How do we setup WT3 for sites with rotating ads? I had turn off the WT3 plugin because it appears that caching pages = static ads. For example, we have a leaderboard ad with two rotating spots. Without WT3, we can reload the page to see the other ad. With WT3, that doesn’t work (and one of our advertisers is upset about this, rightfully so….)

    1. It depends how your ads are generated, but it would amount to writing an exclusion for whatever is generating the ads, such that W3TC ignores them and continues to allow them to be generated dynamically and rotate the ads accordingly.

  47. Great tutorial – thanks so much. My only issue is that it breaks my Soliloquy slider on mobile devices. When I deactivate W3, the slider works again on my iPad. On my laptop all works fine regardless of whether I have W3 on or off – any suggestions or ideas?

    thanks again.

    1. Not without delving into it, but @jthomasgriffin is usually very responsive and helpful, though you might need to open a support ticket if the response is more involved.

    2. Jasper says:

      I had the same issue with a plugin called WP minify, which includes the same code for minifying. It’s the minification of javascript and/or css that probably causes soliloquy to break, you can try excluding the soliloquy css and javascript from being minified… I did not have the patience to research it as of yet, so I disabled minification alltogether.

  48. vinni says:

    Man that was bloody epic! thanks a bundle for putting this information out there!

  49. Ronnie Ann says:

    This is WONDERFUL. Thank you, Dave. I have been so lost. Great tutorial. :)

    One question, if you know the answer: I have both W3TC and Cloudflare, with Cloudflare on W3TC activated. W3TC offers the option to “empty all caches EXCEPT Cloudflare”. But I’ve seen some comments elsewhere saying this doesn’t always work. Is it necessary to use that when I want to empty my caches?

    Thanks!

    1. I would think that you’d want to empty your CloudFlare cache when the cache needs emptying to ensure that everywhere that has a stored copy of your content is forced to get a new version.

Leave a Reply