WordPress Optimization

= Why Optimize Your WordPress Blog? =

There are many reasons why you may want to optimize your WordPress blog. Primarily, you want your site to load quickly. That of course encompasses a number of other things such as wanting to make sure your site can handle large volumes of traffic without choking and making sure your site's processes aren't being killed due to using too many server resources.

While doing this, there are a number of different avenues of attack. You can adjust the configuration WordPress runs in. Do you want caching? No caching? FastCGI? You can adjust your theme to optimize it's load time. You can install or remove plugins to help speed things up as well. Furthermore, you can take several security steps to make your site less vulnerable to being hacked and brought down maliciously. All of this is about optimizing your setup. It can take some time initially, but is generally well worth the investment.

= WordPress Stuff =

What's slowing me down?
A slow site boils down to three reasons:


 * Too much traffic
 * Bad theme
 * Bad Plugin

While you may hear people saying you should use as few plugins as possible, this really isn't the case. You should use only good plugins, but of course vetting them can be a full time job. Generally speaking, you should only use the plugins you need, not the ones you may want, because yes, the more you have might slow your site down. But it's not the plugin's fault, it's just like how having extra weight in your car makes you use more gas. A good idea is to never use more than one plugin to accomplish a task. Have only one stats plugin, for example, and not six. The P3 Plugin Profiler is a great way to see what plugins may be slowing your site down.

Using a good theme is even more challenging. While the ones on wordpress.org are free and safe to use, some are going to be better than others. A fast way to see if your theme is the problem is to change to the default theme (currently TwentyTwelve) and see if that helps your site. When shopping for a theme, do some Google searches to see if people have complained about site speed with that theme. You'd be surprised what you find out.

Remember, it's not just the plugin or the theme or the traffic, but the combination there in. A combo that works for one person may not work for another, because there isn't one right way. Everyone has different audiences and traffic patterns, and that accounts heavily for how your site reacts. Don't get discouraged if you have to fiddle around a lot.

Do I need Caching plugins?
The number one question people have is do they need to use caching and/or a caching plugin. The answer is 'Maybe.' If you aren't getting a lot of traffic, you probably don't need a plugin to speed you up. Usually Google PageSpeed will do enough for you.

If you've already trimmed the fat with plugins, made sure to use a good theme, and pagespeed isn't helping enough, then you should look at WP Super-Cache. It's a very simple WordPress caching plugin that works well on our servers. If that isn't enough, you may need to step up to W3 Total Cache, which while more robust, is also more complicated. Generally speaking, a shared server is best with Super Cache, and a VPS is best with W3TC.

= Server Stuff=

Which PHP do I use?
We have two main options for PHP on Shared Hosting:
 * PHP 5.2
 * PHP 5.3

Each version of PHP has additional options:
 * CGI
 * FastCGI
 * mod_php (5.2 only)

We recommend using 5.3 FastCGI, as it uses the least amount of memory and is most compatible with our servers.

Page Speed Optimization
Unless you're using nginx (more on that later), you can use Google PageSpeed on your site, and most of the time you should. Just by turning it on, it minifies your webpage. That means it takes your pretty formatted source code and gets rid of the extra spaces you don’t use. This is called by using the PageSpeed filter “collapse_whitespace.” Another filter available is “insert_ga” which is how we’re magically able to insert your Google Analytics for you from your panel. That filter automatically inserts your GA code on every page on your domain without a plugin.

There are many filters you can add to your site by editing your  file. You simply include a section like this:

 ModPagespeed on   ModPagespeedEnableFilters remove_comments,rewrite_javascript,rewrite_css,rewrite_images ModPagespeedEnableFilters elide_attributes,defer_javascript,move_css_to_head ModPagespeedJpegRecompressionQuality -1 

You'll want to experiment with what works best for your site.

nginx or Apache
If you're on a VPS or dedicated box, you can use nginx instead of Apache, however you will be limited to PHP 5.2 right now, unless you install 5.3 on your own.

nginx is faster in many ways, but can be more complicated to the new user. It's hard to say which is 'better' since they each have pros and cons. A big con for nginx is right now you're limited to PHP 5.2, and you can't use Google PageSpeed. A big pro is that it's easy to install and use xcache, which can work with a plugin (like W3TC) to speed up your site more.

=See Also=


 * WordPress and PHP - Advanced help in determining which PHP to use and why
 * Wordpress_performance - Additional WordPress performance tweaks
 * WordPress Shared Hosting Performance