Friday, October 19, 2012

Vroom, Vroom: A Comprehensive Guide To Speeding Up A WordPress Blog


Sent to you by Chris Hunter via Google Reader:


via MakeUseOf by James Bruce on 10/19/12

speeding up wordpressMakeUseOf serves hundreds of thousands of visitors everyday, and we do it all on WordPress. WordPress can and does scale from tens to millions of pageviews, but you're going to need some heavyweight plugins and strategies to increase performance at that level. Here's a comprehensive list of things you can do to speed up your blog, and the plugins you can use to do it.

Switch hosting provider

I've explained before about the differences between types of hosting, but it boils down to this: shared hosting is very slow. If you're still running on shared hosting, that is your greatest bottleneck. An incredibly fast virtual private server costs as little as $40/month, and not only gives you an instant speed boost, but allows you to implement server level customization's to speed up WordPress even more.

Host external resources on a CDN

We've talked about CDNs before too; they're just high speed filestores that mirror files in local caches around the world, so while the core site is run on your server, images and Javascript resources are pulled from the CDN, resulting in near instant download times. Without a CDN, you'll find images load sequentially and slowly – you can actually see images as they load in line by line on some shared hosts. Even ignoring the speed benefits, CDNs are far cheaper to host files on than web hosts.

speeding up wordpress

I'd suggest MaxCDN, which I personally use and is very cost effective – but to connect to WordPress side of things you'll need a plugin to change your image and resource URLs to the URL of your CDN provider. w3 Total Cache handles this admirably if you're looking at an all-in-one solution, but for CDN functionality alone, try these:

  • jsDelivr is a free Javascript CDN which will load all the various scripts WordPress uses from their CDN; you can pick and choose which to load. They won't host your images though.
  • WPSuperCache will be mentioned elsewhere; it includes CDN support with the addition of CDN Sync Tool.
  • WPBooster has a dedicated plugin, though the service pricing is far greater than a general CDN.

If you have large files (like music or PDFs) where speed isn't essential, Amazon s3 is an even cheaper option to offload them from your server. It can also be used as a CDN, but isn't as fast (Amazon also does a CDN called CloudFront you may wish to look at).

Minimize text files

HTML and Javascript are generally made to be human-readable; that is, they include comments, unnecessary tabs, line breaks and useful names – all of which make a file larger. Minimization strips out all that unnecessary stuff and compresses the file so it's still perfectly functional, yet significantly smaller. The only downside is that development on a live server can be a little more difficult as the code is obscured, like this:

speeding up wordpress site

A secondary process that's often used with minimization is to combine separate Javascript and CSS files. Each script on your site results in an additional request to the server; combining them all means the whole thing can be grabbed in one with no loss in functionality.

Both can again be done with w3 Total Cache, or you can use the standalone JS&CSS Script Optimizer plugin. The only difficultly with minimization is ensuring the load order is correct; some scripts depend on others, so for example you'll want jQuery right at the top, then perhaps jSON and jQuery UI, then finally your own theme scripts.

Change server software

Most of us understand Apache to be the "web server" software that most sites run on – but it's certainly not the only web server software out there. NGINX is a faster alternative – we use it here at MakeUseOf. WordPress is able to run fine on NGINX, though you'll need to read up on correctly configuring the site. There won't be .htaccess rewrites anymore, for instance, which WordPress uses to make pretty permalinks – the same is achieved in NGINX config files. [Performance test graph from Joe Williams]

speeding up wordpress site

Memcached and APC are additional caching systems that you can install on your server – various caching plugins can then take advantage of this within WordPress, such as w3 Total Cache or WP SuperCache. However, beware that this is pretty advanced, and you may end up breaking your VPS if you do something wrong; be sure to do a full system image backup of your VPS before attempting these kind of adjustments – the same goes for NGINX. These changes are out of the scope of this article, but a Google search for "how to install memcached on mediatemple" or your host will do the job nicely.

Prevent false requests

CloudFlare is a wonderful free service we've talked about before and one of my essential installs on any new site. It acts as a quasi-CDN to cache some of your pages, and also places a firewall between your site and the incoming requests by replacing your hosts DNS. This means it can capture and prevent malicious scans, bots and such from ever reaching your site; freeing up your bandwidth for genuine users. Implementing this is as simple as changing the DNS settings; or if you're hosting with MediaTemple, my favorite VPS provider who recently acquired the CloudFlare service, it's a one-click setup in your account settings.

speeding up wordpress

Make things static

WordPress blogs are dynamic and database driven – that means that each time someone views your site, WordPress will run around gathering what it needs from the database and generating the page. But realistically, the page doesn't change that much, unless you update it or someone adds a comment. So why serve a fresh copy each time? This is the core function of caching plugins w3 Total Cache and WP SuperCache. If you want to take this to an extreme though, WP Static HTML Output will generate completely flat HTML files of your entire site. You can even use this plugin to create your WordPress site offline, then upload the finished compiled site anywhere. It's important to bear in mind that dynamic page elements stop working when a page is cached – so look to third party Javascript solutions, such as LiveFyre or Disqus, for commenting.

Cut down on plugins

Yes, I realise the irony of suggesting you remove plugins in an article about which WordPress plugins to install. Removing plugins need not mean losing functionality though: consider alternatives such as embedded Javascript polls instead of a polls plugin; or consider hardcoding some of the functionality  straight into your theme files.

For instance, instead of having an entire plugin just to add some share buttons at the end of each post, open up the single.php template file and learn how to add them yourself. Instead of hosting your own image gallery, consider uploading Flickr then using widgets to display them.

Does this really help with speeding up WordPress? Yes – every plugin you have needs to read a set of options from the database each time it runs, all of which slow down the core page load times. The more things you can remove from this chain, or offload elsewhere entirely, the faster your blog can run.


I set out to provide a comprehensive overview of all the ways of speeding up a WordPress blog, and I'm pretty certain I've achieved that. If you think I've missed something, I'd love to hear from you in the comments. If you appreciate this post, please share it with your friends, and be sure to check out all our development focused articles.


Things you can do from here:


No comments:

Post a Comment