Editor’s note: Caching plugins like W3 Total Cache are often blacklisted by managed WordPress hosting plans. These hosting plans frequently have caching built-in, which may conflict with caching plugins.
How would you like to improve your site speed, boost SEO, and save on bandwidth? You can accomplish all of this and more in WordPress with a properly configured installation of the W3 Total Cache (W3TC) plugin.
W3TC delivers blazing speed. A site that loads fast will help you acquire and retain users, and give them a great experience from the moment they arrive. You’ll also achieve a better ranking in Google.
It’s no wonder this is one of the most loved plugins in the WordPress Plugin Directory, with more than 1 million active installations and a rating of four and a half stars out of five. On top of that, it’s free. If you also configure WordPress with memcached on your server, your speed boost will be even more dramatic.
A site that loads fast is key to ensuring a great experience for your users and is a critical factor in user acquisition and retention. Fast loading also helps obtain a better ranking in Google.
W3TC claims it can make your site 10 times faster using a three-pronged approach:
Content Delivery Network (CDN) integration
Cached static resources can be mirrored on a CDN, meaning they will load even faster. Start harnessing the power of a CDN such as Amazon S3, which offers plans that start for free for a full website with backup.
W3TC doesn’t modify your actual website files. Instead, it makes optimized, minified copies and stores them in the cache. It works with nearly any type of hosting, including shared hosting, and it can be paired with most popular CDNs.
It comes with a ton of options, and if you don’t set it up well, you won’t get the performance boost. No worries though — in this article, we’ll help you set up a configuration that will take your website to the top of the speed charts. This is especially true if you take advantage of PHP’s memcached technology.
Installing and activating memcached
Memcached is a technology that caches frequently used MySQL files and queries in server memory. WordPress makes A LOT of queries, so this can save a significant amount of time and resources on the server side, making your site load more quickly. This is separate from W3TC, but works in conjunction with it. To use it, you must first set it up.
Editor’s note: We recommend doing this on a VPS or Dedicated server, otherwise your hosting plan might not have enough resources for memcached to be useful. For GoDaddy customers, you’ll need to install memcached first: here’s how to do it on CentOS and Ubuntu.
Here’s how to activate memcached via cPanel:
- Log in to cPanel.
- Scroll down to the Software section and click Select PHP version.
3. Click the link to Switch to PHP Options.
4. On the Options screen, ensure that memcached is selected.
5. Save your changes.
Memcached will now be enabled and you can use it with W3TC.
Installing W3 Total Cache
Installing W3TC is as simple as going to Plugins > Add New in the WordPress Admin Dashboard and searching for “W3 Total Cache.” Select the plugin and click Install Now. Then click Activate. This will add a new Performance menu to your dashboard.
If you hover over the Performance item on the sidebar, you’ll see that it contains 17 items:
- General Settings
- Page Cache
- Database Cache
- Object Cache
- Browser Cache
- User Agent Groups
- Referrer Groups
- Cookie Groups
- Fragment Cache
Don’t panic when faced with all of these potential settings, because you won’t have to touch most of them. Some settings are applicable only to premium plans and others are linked to private server environments only or are relevant only in conjunction with additional software. If you want a detailed run-through of each of these 17 submenus, check out this wpmudev article. If you want to dive right in to basic configuration, keep reading.
While there are settings on most of these submenus that can boost performance, the most important settings are found under General Settings, Page Cache and Browser Cache. That’s because these are all it takes to produce measurable improvement in your site’s performance. The following guidelines will help you set up W3 Total Cache in a shared hosting environment.
Although it’s not required, it’s a good idea to run a compatibility check. This will tell you what the plugin can and cannot do with your server configuration. To do this, select the Performance > Dashboard submenu and click Compatibility Check.
This will display lots of information about what is and isn’t installed in your server environment.
If you’re on shared hosting, you probably can’t fix some of the compatibility issues, but don’t worry, you can get W3TC working for you anyway. At least you’ll have an idea of what you’re dealing with.
General Settings menu
Next, go to the General Settings menu. It’s a good idea to enable preview mode, as some settings, particularly minify settings, have the potential to break your site. Preview mode allows you to view changes in a separate browser and try them out before you deploy them.
Scroll down and click the checkbox to enable Page Caching. If you’ve installed memcached, set the Page Cache Method to Memcached.
Scroll down to the Minify section.
Try the Auto setting first. If you’ve installed memcached, set the Minify Cache Method to Memcached.
Next, scroll down to the Browser Cache section and click the checkbox to enable that. This tells the visitor’s browser to save a copy of the page, reducing calls to your website and speeding loading.
Click any Save all settings button to save settings at any time.
If you’re using a CDN, you can also enable it in the General Settings. The set up depends on the CDN you’re using. However, W3TC will also work without a linked CDN.
Page Cache menu
Next, you’ll fine tune the Page Cache settings. Select the Performance > Page Cache menu from the left toolbar. Set it as follows:
Note that your menu here might be slightly different depending on your site setup. For example, the “Don’t cache front page” checkbox may instead say “Cache front page” — in which case you should check it. Either way, you want the setting that will cache the front page.
Next, scroll down to the Cache Preload section and select the following settings:
Click Save all settings.
Browser Cache menu
Finally, go to the Performance > Browser Cache menu. Leave the defaults, but make certain the following items are selected:
- Set Last-Modified header
- Enable HTTP (gzip) compression
- Disable cookies for static files
Save all settings.
Once you’ve adjusted these settings, use the “Preview” button to check out your site and make sure it’s functioning well. If so, hit Deploy, and you’re good to go.
Otherwise, the cached version might get out of sync with current site. You can work around this by going to Performance > Dashboard and emptying the caches every time you make a change, but that can quickly get tiresome.
Although the above steps are all you need to get W3 Total Cache and memcached working, there’s plenty more tweaking you can do to speed things up even further. Linking a CDN such as Amazon S3 or CloudFlare (formerly MaxCDN) will notch speed up significantly. You might also try enabling database caching (under General Settings). If so, set the Database Cache Method to memcached if you have that installed. As you try new things, use speed test tools like Pingdom Website Speed Test or WebPagetest to monitor your progress.
Before you go too crazy, make a backup of your working W3TC settings. You can export your current configuration from the General Settings submenu (it’s the last item). Then if something goes awry, you won’t have to start from scratch.