The top 2 ways to turbocharge your WordPress blog

How many times have you left a site because a page took too long to load? Even a few seconds is too long in today’s “I want it now” age.

Creative Commons licensed photo
Photo by bcmacsac1

There’s a lot of things going on under the hood when WordPress loads one of your pages. By tweaking everything you can get a wrench on, you’ll increase the performance of your site noticeably, or even significantly.

This article explains some quick and easy ways to put more horsepower under the hood of your WordPress site, keeping your visitors from going away mad.

Cache your blog pages

Cached pages load in a fraction of the time compared to the default method used by WordPress. Each time WordPress displays one of your pages, it must first access the database to retrieve the requested page.

A cached page is stored in a static file the first time it’s requested. Subsequent requests for that page are generated from the static file, decreasing the load time from tenths of a second (sometimes seconds) to milliseconds.

WP-Cache, a WordPress plugin, provides the caching capability by eliminating the need for the PHP code to be loaded, interpreted, and subsequently built from the database then served to your visitor.

Hard code your header file

For every page your WordPress platform delivers, the header file (header.php) is fetched and parsed. The value for each PHP tag <?php something(value_of)?> must be determined and inserted into the code before the page is rendered.

This applies to other template files as well, but having several of these in your header file as most WordPress headers do, slows things down unnecessarily.

Example: note the red portions in the following code:

<head profile="http://gmpg.org/xfn/11">
	<meta http-equiv="Content-Type" content="<?php bloginfo(’html_type’); ?>; charset=<?php bloginfo(’charset’); ?>” />
	<title><?php if (is_single() || is_page() || is_archive()) { wp_title(”,true); } else { bloginfo(’description’); } ?> — <?php bloginfo(’name’); ?></title>
	<meta name=”generator” content=”WordPress <?php bloginfo(’version’); ?>” />
	<link rel=”stylesheet” href=”<?php bloginfo(’stylesheet_url’); ?>” type=”text/css” media=”screen” />
	<link rel=”stylesheet” href=”<?php bloginfo(’template_url’); ?>/style_wpp.css” type=”text/css” media=”screen” />
	<link rel=”alternate” type=”application/rss+xml” title=”<?php bloginfo(’name’); ?> RSS Feed” href=”<?php bloginfo(’rss2_url’); ?>” />
	<link rel=”pingback” href=”<?php bloginfo(’pingback_url’); ?>” />
	<?php wp_head(); ?>
</head>

Each time these bits of code are encountered, extra work must be done behind the scenes to find and insert the necessary data into those locations. The more portions of code you have requiring this extra work, the longer your page will take to load.

In that short section of <head> code above, there are 10 instances where PHP is used to populate the code with a value retrieved from the database.

How do you avoid this unnecessary slow down? Hard code it!

<?php bloginfo(’html_type’); ?> becomes text/html.
<?php bloginfo(’charset’); ?> becomes UTF-8.
<?php bloginfo(’name’); ?> becomes WP Project.

And so on… you get the idea.

You may not want to hard code everything. For instance, I have Feedburner managing my RSS feeds through a plugin. If I de-activate my feedburner plugin for some reason, with my header file hard coded, the RSS subscription option will fail.

To be safe, only hard code values into the header file that you’re sure will not be changing. E.g.: the name of your blog, template path, etc.

Not fast enough for ya?

If your site is already turbocharged, give it a Nitro boost too with the tips and tricks found in these articles:

More turbo tips

  • Run the latest version of WordPress
  • Choose a good Web host
  • Host your post images on Flickr
  • De-activate or remove unused plugins
  • Add define(’ENABLE_CACHE’, true); to wp-config.php

Advanced turbo tips

  • Enable compression in php.ini or .htaccess
  • Remove the “Last-Modified” header
  • Implement a custom php.ini file - here’s how
  • Activate the Mysql Query Cache in my.cnf
  • Optimise your Mysql database

If you’ve found this article helpful or have some other tips, why not say so in the comments section below?

Subscribe to WP Project
If you found this article useful, please comment, share, or subscribe.
Print This Post
Comments
1

Good post, i always thought about hardcoding the header and this post has finally made me get around to doing it. :)

2

One of the things that affects page load speed the most is the number of *separate* files (css /javascript, etc) referenced from your page. Even if the files themselves are small, the overhead of making the connection is what kills performance.

YSlow from Yahoo (http://www.yahooapis.com/yslow/) can help identify this, and other issues.

HTH

3

[...] There are plugins available to help optimize your title tags, however, editing one line of code can help you avoid an additional plugin. To me it’s worth it—less plugins, better performance. [...]

Have your say

(You'll have 5 minutes to edit your comment after it's submitted)

(required)

(required · hidden)