The ultimate guide for making WordPress fast
WordPress is a popular, open source blogging platform and content management system (CMS) used by millions of websites all over the world. Its ease of use makes it attractive to beginners whilst its modular architecture appeals to advanced users who want to tweak it for specific needs.
Anyone with basic computing skills can get a hosted blog up and running on wordpress.com in a few minutes. You can also download and install the application to your local machine, in case you want more control over it.
In and by itself, WordPress is impressively fast, but it can be made faster. This article will explain simple steps which one can apply to a self hosted or wordpress.com hosted installation to get better performance. The intended audience for this article are intermediate users who can find their way around the innards of a WordPress installation. This article uses some of the tools and technologies described in the optimization tools section, so it is advisable if you can become familiar with those tools.
So lets get on it!
A little background: The Architecture of WordPress
WordPress is a web application developed with PHP and MySQL as the database. The web applications primer on Wikipedia details how web applications work. You might want to go through it to understand the technology behind web applications.
Step 1: Get and learn the Tools
Before you start, you need to find out exactly how fast or how slow your WordPress is at the moment. This is called profiling and there are many free and commercial tools out there to enable you achieve this. We have reviewed several in our optimization tools section. You should familiarize yourself with PageSpeed, Pingdom and W3C Validator.
PageSpeed provides and overall score of the performance of a website, calculated out of 100. We will be using this figure and trying to make it as closer to 100 as possible. It is available as a Firefox addon as well as a hosted service.
This tool will provide us with a more realistic load time of all resources on the website. Our target is to get the least possible load time and the least number of resources to download.
The W3C Validator primarily checks for proper use of HTML from a usability perspective.
Using each of the tools above will give you a pretty good idea of how your blog is currently performing. Record these performance scores somewhere because you will use these tools again after completing the steps below, thus, you can compare the impact of your optimization.
Step 2: Cache
If you want to achieve an immediate performance gain on your WordPress blog, enable cache.
The concept behind cache is pretty simple. The first time a user opens a page on your blog, that page is generated by PHP with content from the database. This page is then saved to a HTML file so that the next time that user or any other user access the same page, the user is given the cached page instead of generating a new one from scratch, thereby saving time.
Caching in WordPress is easily enabled using plugins.
WPSC speeds up your blog by storing the HTML generated by PHP in static HTML files on the hard disk and then serving these up to Apache thereby saving on MySQL database hits as well as PHP hits.
This plugin is slightly different from WPSC in that it caches the database queries issued by the PHP engine to the MySQL database. Ideally, this means that each database query will get executed once for the given session.
WPSC used in conjuction with DB Cache Reloaded have the capability of significantly increasing the performance of a blog especially if the blog is hosted on a slow or heavily utilised server of if the blog has high traffic.
Step 3: Optimize Images
Images by their very nature often constitute the biggest, in terms of size, resources a website has. This is made worse by the fact the image may be using the wrong file format or an excessive color palette, thus using more space than it should.
This plugin assists you to optimize your images by using the Yahoo Smush-it API to make them smaller while still preserving their quality. This optimization is done everytime a page or post with images is loaded.
A more permanent solution would be to permanently optimize all the images on your blog by using the Yahoo Smush-it API directly. The benefit of this is that you will do it once for all images, instead of everytime someone visits your blog.
A more detailed walk through on how the same can be achieved by using typical image editing applications is available in the image optimization section. This might be useful if you do not want to install the Smush-it plugin.
- Comments and whitespaces are stripped out
- Headers are added to each file to enable the user’s browser to cache them.
- The two files are then compressed using Gzip.
Step 5: A Lean and Mean WordPress
A default installation of WordPress comes with very few plugins (3 plugins, as of version 3.1), but with time, the installed plugins may become many as you seek to add more features. Given the fact that active plugins are loaded when WordPress starts, then it is a very wise idea to deactivate and eventually uninstall all plugins that are not being used.
To find out what impact plugins have on your, make sure cache is deactivated, then profile the page using PageSpeed or Pingdom, deactivate the plugin then profile the page again. In an ideal situation, this will give you an idea of the impact of that plugin.
Step 6: What next?
It would be a good idea if you ran PageSpeed and Pingdom on your WordPress installation after making each change detailed above, so that you can see the speed or size changes or lack of thereof. Doing that will give you a pretty darn good idea if you are wasting your time or are indeed squeezing the last drop of speed from your setup.
If you have applied the guidelines in this article and you still want more, the next step will be focusing solely on optimizing the database, MySQL. Other articles in this series also focus on optimizing Apache as well as the operating system on which all of these softwares are installed.
- WordPress Performance
- Yahoo Best Practices for Speeding Up Your Web Site
- PageSpeed Web Performance Best Practices
- Ross Shannon’s Optimising Images
- WordPress Stats
- WordPress Plugins