How to speed up your WordPress Blog

Friday, June 18th, 2010 | Business | by

I finally got around to speeding up my WordPress blog and wanted to share with everyone the various things I did.  I reduced my average page load time on certain pages from 15 seconds to about 1.5 seconds.  That’s a big change.

My favorite test was a quick click through.  On my new host I timed 6 page loads down to about 5 seconds.  When I did the same test on my old setup, it took about 20 seconds (I know, below the 15 seconds average, that was really only for 1 page, but one of my most trafficked pages).

Some of the things I did were:

  • Change web host
  • Enable “Deflate” on Apache
  • Rebuild my WordPress Header / Footer
  • Modify CSS to appear to load faster
  • Removed Unnecessary Plugins
  • Tweaked Existing Plugins
  • Enable and Tweak WP-SuperCache
  • Tweak Apache’s configuration
  • Change Advertiser Settings

Before we get into everything, the tools I used were:

  • Chrome – Using the Developer Tools (Ctrl + Shift + J) “Resources” tab is infinitely useful in tweaking web page performance.  You can see how long it takes for assets to load, see which assets are holding up your page load, and in general troubleshoot your site’s load
  • Putty – An excellent SSH client, useful all around
  • Media Temple – Yes, I switched to Media Temple hosting.  I had run a test for about 2 months on various hosting platforms, Media Temple won.  You can see a list of other web hosts on my How to pick a web host post.

Change Web Host

One of the most important changes that affected my speed increase (I believe) is changing to an overall faster host.  Without any modifications my page speed load was cut in half immediately.

Beyond that the new web host, Media Temple, lets me have full control over my server so I can tweak the server / apache configuration at will.

Overall the server was faster, ping times were 1/3 of what they were before (from 80ms to 15-20ms), and the database server seemed much stabler.

Enable “Deflate” on Apache

Deflate will gzip assets leaving your web server.  The change took a few tries to get everything compressing correctly.  It was useful testing the gzip compression on my server at each step.

While it takes CPU power to compress pages going out, this makes up for less total data going out.  I believe on certain assets you get 80% compression.  Plus at those rates, you increase your available bandwidth 4x (probably more like 1-2x when figuring in images that aren’t compressed).

Rebuild my WordPress Header / Footer

The header.php, sidebar.php and footer.php files in my theme have operated as is for a while.  I finally made the decision to customize them for my own purposes.

  • Convert static values to HTML
  • Replace data that doesn’t change with HTML
  • Remove “commented out” elements

What’s to customize, they already work?  Well yes and no.  Yes, they work, but only because they were made to be generic.  You can’t distribute templates that only work for a certain site.  WordPress likes to constantly ask the database for RSS path, CSS paths, Home page paths, blog title, blog description, and some other pretty static elements for a single site.

I just went through and decided to fill in these requests with plain HTML.

The net effect wasn’t too much for me, as you will read later, since I installed caching in WordPress.  However, I’m sure it made a difference (it’s really a no brainer).

Modify CSS to appear to load faster

This might seem stupid, but it has a big effect for me.

This site uses a Theme (I know, no custom design? … It’s easier).  The theme had an image that aligns bottom with the page load (that gray flower like pattern at the bottom).  That image wasn’t pushing down until the page filled in with data.  Even with an average of 500ms until that happens, it was still annoying.

I just added a min-height to the body so the image at least loads further down where it isn’t as obvious (on a white background instead of black).

It sounds superficial, but affects the perception of page load time.

Removed Unnecessary Plugins

I was of the belief that if you had a plugin deactivated it wouldn’t affect your page.  Wrong.

There were styles being included for deactivated plugins, and JS files.  Maybe it was because it was cached, but they were there.

Plus, if they haven’t been used for 2 years, why keep them updated?  So out they went!

Tweaked Existing Plugins

I looked at my page source and saw that with all the various plugins I had, Google analytics code was being loaded THREE times!  It hasn’t been tracked that many times (Google must be smart that way) but still, that is 3 requests sent out to Google.

I troubleshot the problem, and found out that Headspace2 and Google Analyticator thought they were handling my Google tracking insertion.  I stuck with Google Analyticator.

I also went through all my plugins and picked out the ones I haven’t used since I started (even though they were still enabled).  Those are out.  Kodak Gallery plugin was powering a single page, but was adding 200ms on to every page request.  I can live without that one.

Enable and Tweak WP-SuperCache

Nothing affected page load time more than enabling WP-SuperCache (by Donncha O Caoimh).  My other host didn’t support this plugin (it’s difficult to get it working on some hosting platforms) — and I didn’t have shell access to fix it.

Installing WP-SuperCache is the first step, after that it was making sure all pages were being cached.  Turns out initially, ONLY the home page was being cached.  The “strings that forces a page not to be cached” was colliding with the “friendly URLs” and not caching anything without “.php” so I deleted the default rules.  Hey, there’s nothing I don’t want cached.

Some other useful tweaks were setting up the Cache Preloader — every 4 hours my site is auto indexed.

Tweak Apache’s configuration

I modified Apache’s configuration a bit.  I made sure Keep Alive was enabled, and mod_deflate was enabled.

Also I modified the number of servers and other parameters for how many requests can be handled.  Initially I was too aggressive, but after some testing I came to some good values for my server.

Change Advertiser Settings

One of the nice things about this blog is I don’t consider it an important revenue source (which is good since it earns about $0.20 a day).  Using Chrome’s Developer Tools I saw that one of the advertising options (that I didn’t know was enabled), underlined inline text, was causing page load to take an additional second.

I fixed that right away.

I also saw that some of my links to Blog Catalog were taking forever to load their images. Blog catalog is responsible for virtually 0 traffic to this blog, so out it went.

Let me know what everyone thinks of the new host and configuration!

Oh, and last but not least, I upgraded to WordPress 3.0!

Related Posts

Tags: , , , , , , , , , , , ,

2 Comments to How to speed up your WordPress Blog

cell phone signal
June 20, 2010

I use WP Super-cache and help me much in optimizing website speed.

[…] graph below shows why.  Last week on Thursday I significantly improved the page load performance of this site.  According to various metrics average page load was around 8 seconds before the […]

Leave a comment

*


Please share, it makes me happy:

Subscribe to Email Alerts

Follow Me

Follow seangw on twitter

Archives

Categories

prestashop theme

virtuemart template