Always Get Better

Posts Tagged ‘wordpress’

Accelerate Your Site with a Content Delivery Network

Thursday, April 21st, 2011

The best way to keep visitors engaged in your website is by delivering your experience in as little time as possible. The average visitor will only stick around for a few seconds, so it is important to get them interacting with your content fast. The first thing to check for, of course, is any bottlenecks in the initial page generation. Once the web page is being generated quickly, we can turn our attention to the next biggest culprit: the connection to your client.

Downloading files directly from a web server is costly, even if you’re using an efficient server like nginx for static files.

A content delivery network (CDN) can help speed up the process by storing your content in data centres around the world so they get served to your visitors from locations that are physically close to them. This results in fewer network hops which makes the files download faster, and reduces the overall load on your web server so you can focus on doing more interesting dynamic application stuff.

At one point, CDN services were only available to companies with deep pockets and huge websites, but these days anyone can set up and use an inexpensive service with their regular hosting provider.

Check with your host to see if they offer a content delivery solution. The two providers I use for my blog, Media Temple and Rackspace both have excellent services. If you are using a WordPress site, check out W3 Total Cache, which provides an all-in-one package for managing your files and optimizing the overall speed of your site.

How to Move a WordPress Database

Saturday, April 4th, 2009

One of the most common requirements for web developers is the ability to switch code from development servers to live production environments. This can be tricky if you’re working with WordPress; moving the files is dead simple, but since WordPress uses canonical URLs you have to be careful if you are trying to transfer any of your database content.

Canonical URLs force your site to use the same base path ( rather than But if you are working in a development environment – e.g. the development site’s address isn’t the same as your web site, but is rather something like – you need to be able to make the switch to WordPress without bringing your site down.

Since I end up having to look for this information so often, here are the steps I use to accomplish this amazing feat:

Download The Database

From the shell prompt of your server, dump WordPress’ MySQL database into a backup file:

mysqldump –-add-drop-table -uusername -ppassword databasename > mysqlbackup.DATE.sql

Move it over to the new server and run this command to overwrite your target:

mysql -udb##### -p db#####_dbname < mysqlbackup.DATE.sql

Update the Database Paths

Log into your MySQL database and issue this update command to ensure WordPress redirects to the new server:

UPDATE wp_options SET option_value = replace(option_value, ‘’, ‘’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;

Next update the post URLs:

UPDATE wp_posts SET guid = replace(guid, ‘’,’’);

Finally, update your posts’ content to fix any internal links:

UPDATE wp_posts SET post_content = replace(post_content, ‘’, ‘’);

That’s all! Repeat these steps when moving from production to development and vise-versa.

As I said I typically search for this information whenever I need to move WordPress sites. I find the SQL queries at:

Post-Dating Blog Entries in WordPress (or, the Absent-Minded Blogger)

Sunday, December 7th, 2008

WordPress is a great tool; I am looking forward to version 2.7 although I find myself hard-pressed to try to imagine how the WP team is going to improve upon the existing platform. One of my favourite functions of the WordPress software is the ability to post-date entries. Often I will get a burst of inspiration and write four or five articles.  Rather than releasing them all at once I will set them to automatically publish into the future so there is a steady stream of content always appearing on my home page.

Most cream-of-the-crop blogs add 2-3 new entries daily. Always Get Better is certainly not in that category, however I try to post at least once per day. As I am busy with other work and blogs, I don’t necessarily have the time to write a decent article every day (although I do often make the time). Since the content here is not particularly topical, it doesn’t matter too much if it doesn’t go up hot off the press. In fact, by pre-publishing my articles I have a decent opportunity to go back and review what I’ve written which improves the overal quality of my writing.

Some blogs exclusively post content written long ago. I certainly don’t advocate going to that extreme though since a blog that is totally on autopilot risks losing some human connection. As long as the authors review, post and respond to comments in real time I suppose it wouldn’t matter in the long run.

Improving WordPress Page Titles

Saturday, November 29th, 2008

Anyone half-serious about running a large blog knows that search engine ranking is critical to getting properly indexed. Over 90% of the traffic to Always Get Better originates from search engine traffic – therefore the ease of which Google (among others) is able to index this site is the life-blood of its continued success.

WordPress is a terrific platform with out-of-the-box support for many of the critical elements necessary for site building: CSS layouts, RSS feeds, track backs. But the glaring problem with WordPress is the default title format: “Blog Name > Blog Archive – Post Title”. What is that!?

Many search engines only catalogue the first several characters of web page titles. If the title of your post is at the end of the page title, it may get cut off in favour of your blog’s name!

The simple solution is to reverse the code as explained at the WordPress garage (and quoted below for convenience):

You can switch it through the use of plugins, but if you want to avoid using another plugin you can fix this in the header.php file. Find the code that starts with <title>, and replace what is currently there with this:

<title><?php if ( is_single() ) { ?> <?php wp_title(''); ?> &raquo; <?php } ?><?php bloginfo('name'); ?></title>

Apache: Enabling mod_rewrite on Windows 2003 Server

Monday, April 21st, 2008

Recently I had to set up a WordPress blog on a Windows 2003 server, which involved installing Apache, PHP and MySQL.  Everything went pretty well – except for the typical PHP.ini problems I shall write about later.

Once the database was set up and I had the blog running, I tried to adjust the permalink structure using .htaccess rewrite rules so they would be more human-readable.

Out of the box, mod_rewrite isn’t enabled on Windows Apache.

The steps I took to resolve the problem were:

  1. Uncomment the line containing ‘LoadModule mod_rewrite modules/
  2. In the VirtualHost directive hosting the blog, add ‘AllowOveride All
  3. Restart Apache

It works like a charm, now.  All the tools ship with Apache, it’s just a matter of configuring them as needed.