Why PageSpeed?

When Google decides which pages to show you in response to your search, one of the criteria is the speed of your site.

It is just one of the criteria that Google uses, and not the most important one. Nevertheless, it is easier to improve than other criteria.

Google changes its rules once in a while; my recommendations are valid for March-April 2015.

You can check what Google thinks about the speed of your site from PageSpeed Insights; you enter the web address of your page and run the tool on it.

At the time of this writing (February-April 2015) PageSpeed Insights give this page 100 almost always, with the exception of seldom cases when the response time of my server exceeded 0.2 seconds required by PageSpeed Insights for 100 grade.

PageSpeed grade is not identical with the speed your page loads: your page may load very quickly but still have mediocre PageSpeed grade if, for example, it requires many roundtrips to the server to pick up additional files which may take longer time for users who are further away.

One of the requirements of PageSpeed is that the above-the-fold part of the page be loaded quickly; above-the-fold means the part of the page that is displayed initially by the browser, similarly to the top part of a folded newspaper.

Importance of caching

For a WordPress site, a caching plugin is the first tool to achieve high PageSpeed grade.

Caching plugin helps in two ways:

  1. Cached page is served much faster than a page that needs to be created by WordPress engine.
  2. Caching plugin often rearranges the flow of data from the server to the browser so that the above-the-fold part of the page is loaded faster and with less roundtrips.

WordPress caching plugin: W3 Total Cache

W3 Total Cache is one of the most popular caching plugins that strives to be a complete framework, and it indeed gets very close to that.

I recommend using it together with another plugin, Autoptimize, that performs one of the tasks, Minifying, better than W3 Total Cache.

W3 Total Cache has plenty of great functionalities but is short on documentation and support. For these reasons its setup is not easy.

I give here my recommendations and explanations how to configure both plugins. These recommendations and screenshots refer to W3 Total Cache version 0.9.4.1 and (updated April 17, 2016) Autoptimize version 2.0.1.

There are many guides how to confugure W3 Total Cache plugin; however, I had difficulties with most of the advice I have found on the net, and my setup differs from all I have read. Apparently the reasons are that Google PageSpeed requirements change, the W3 Total Cache plugin changes with time, and the settings that worked fine earlier, are no longer good.

Since I have figured out how to configure this plugin, my PageSpeed grades are almost always 100, my pages are served lightning fast (usually under 0.2 sec for html to produce the above-the-fold part and satisfy PageSpeed, and about 0.5 sec for the full page), and my server load went way down as reported by my server provider.

Installing W3 Total Cache

Backup your site

Caching plugins often poorly interact with other plugins, and this is especially true for W3 Total Cache. Its reviews have plenty of complaints about websites being broken when W3 Total Cache was installed, and I think that mostly this is caused by poor interaction with other plugins. Without fully understanding the code one usually cannot know what happened or which one of the conflicting plugins is to blame if at all.

For this reason, back up your site before you start. It is even better to try this plugin (as any other plugin) first on a non-live copy of your site to see if it breaks anything. (I keep a copy of my site on my home computer as localhost and try all significant changes there before I propagate them to my live site.)

One case of such poor interaction is listed below.

I think that Minify facility of W3 Total Cache has more poor interactions than Page Cache and Browser Cache, and my suggestion to replace Minify with Autoptimize may help remove many troubles.

File permissions

The installation directions start with the following:

Deactivate and uninstall any other caching plugin you may be using. Pay special attention if you have customized the rewrite rules for fancy permalinks, have previously installed a caching plugin or have any browser caching rules as W3TC will automate management of all best practices.

This is quite understandable. However, the next part is unusual for a WordPress plugin:

Also make sure wp-content/ and wp-content/uploads/ (temporarily) have 777 permissions before proceeding, e.g. in the terminal:

# chmod 777 /var/www/vhosts/domain.com/httpdocs/wp-content/

using your web hosting control panel or your FTP / SSH account.

After finding and installing W3 Total Cache plugin in a usual way, restore the permissions:

Set the permissions of wp-content and wp-content/uploads back to 755, e.g. in the terminal:

# chmod 755 /var/www/vhosts/domain.com/httpdocs/wp-content/

I do not understand the reason behind these sneaky directions but recommend following them. (In fact, I did not notice these directions when I first installed W3 Total Cache, and it malfunctioned. I uninstalled the plugin completely and installed it again following all the directions including these ones, and it worked fine. However, I am not certain that these directory permissions were to blame.)

Conflict with WordPress HTTPS (SSL) plugin

WordPress HTTPS (SSL) plugin can be used to set up secure (SSL) access to the admin areas of your site even if you run it on shared hosting without having a dedicated IP and your own SSL certificate. The trick is to use the server’s IP and certificate, and access your admin area not through your site address but rather through your server address. The detailed directions can be found here.

Unfortunately, these directions do not work with W3 Total Cache plugin which gets confused by the different paths.

  1. Beatty says:

    This is the most comprehensive and helpful posts I’ve read on using W3Total Cache. Thank you so so much. Turned a website I was working on from a C- to an A. Still some issues, but at the very least the site loads a lot quicker. I had a lot of trouble in the past with the plugin and had decided it was more trouble than it was worth. Until now, that is. Thanks again.

    • Baruch Youssin says:

      If you followed the directions including the permissions above, and the error message does not indicate the source of trouble, you need to debug your site.
      Could be W3TC interacts with another plugin you have.
      I would start with removing (not just disabling) all plugins and then trying to install W3TC again following all the above directions.
      If you succeed, you have plugin interaction.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>