If you want your WordPress site to run at its fastest, you should enable caching on your site. W3 Total Cache is by far the most popular caching plugin for WordPress, but it might not be the best option on shared hosts. In this post, I want to go over several common problems setting up W3 Total Cache, and I also want to explore other options for caching a WordPress site on shared hosting.
Get the Proper Caching Setup on Your Server
If you have a choice, you should select a host that knows how to tune php and offers an advanced caching setup.
APC, Eaccelerator, XCache and Memcache – any of these options means you’ll be caching to memory instead of the disk. If you cache database and objects onto the disk, this can affect disk i/o, especially if you have multiple sites on a server all trying to write to the disk at the same time. This problem can be alleviated somewhat by having SSD hard drives on your server, but the best option is to have some form of memory caching available on your server.
Object Caching vs. Database Caching vs. Page Caching
The major factors affecting a site’s speed are object caching and page caching. Page caching + object caching and also a CDN should be the bedrocks as far as optimizing the speed of your site. Many hosts will recommend having DB caching disabled. Since most WordPress database queries only take milliseconds, you really don’t need it to enable it to boost performance.
W3 Total Cache on Shared Hosts
Most people who are on shared hosting will only have Disk caching available to them:
- Make small changes and see if your YSlow score changes for your site. Enabling/disabling object caching is something you might want to test.
- If it says you have “Disk:Enhanced” available, but the plugin gives you an error message after you activate Disk:Enanced caching, then you need to update the htaccess as explained here: http://wordpress.org/support/topic/w3-total-cache-page-cache-url-rewriting-is-not-working-error. Note that you have to copy the code from the pastebin that’s linked in the post and replace ‘yourwebsite.com’ with your domain.
- Once you have your W3 Total Cache plugin settings optimized, you can save your settings to a file. Then the next time you add a new site to the server, you just need to upload the settings file directly to the wp-content folder of the new site.
It’s important to note that if the above options are all that you’ve got, then you CANNOT cache your database as this will add disk i/o latency.
What About Adding a CDN on Top of W3 Total Cache?
Use Other Plugins to Further Improve Your Page Load Times
- Try adding the WP Minify plugin to the mix (while disabling minify in the W3TC settings).
- Use the Google Libraries plugin: http://wordpress.org/extend/plugins/use-google-libraries/. This will help with your site’s load time since all the jquery stuff will be served from Google’s servers instead of yours. As an added bonus, since many large sites already use the Google Libraries, most of your visitors will already have a cached version of the library in their browsers when they come visit your site.
- Be careful with certain plugins that circumvent your caching instructions. A good example is the popular plugin WP Touch which will force PHP code to run when serving up your pages to mobile browsers.