Use a quality host
Maybe I’m stating the obvious, but don’t expect to get the speed of a Ferrari on a crappy shared host. When your blog is young, new, and receives only a few visits per hour, most web hosts are good. But the day your site becomes more popular, you’ll see it takes a while to load.
I remember when Cats Who Code were hosted at one.com, all was fine until I started to get more than 5000 unique visitors per day. Then, my blog loading time started to degrade. Most websites have to switch from a hosting plan to another, and some have to switch to a new host. I switched to Vidahost and I’m happy with them. I’ve heard a lot of good things about A Small Orange as well so you might want to check them out.
Be careful with external requests
When your blog loads slowly, a definite question to ask yourself is, “Do I really need that stupid widget?” or “Is Google Adsense a good thing for my blog?” and so on. In fact, it is funny to see how many people are struggling with loading time when not thinking that maybe, the super widget you placed in your sidebar was a piece of crap.
Each widget like “Facebook fans”, “Latest Twitter entries”, advertisements such as Google Adsense and buttons like the well-known Digg button have to load content from other sites. By using these, you are making your site dependent on other sites. If you’re using a Digg button in your blog, and the whole Digg site is down, your blog will not load correctly.
Make use of caching
The first two tips I gave you should have already helped you a lot to get a quicker loading website; but, especially in case of high traffic websites, this may be not enough.
Caching is a popular technique that has proven great results. The following example features a very simple caching implementation:
<?php // start the output buffer ob_start(); ?> //Your usual PHP script and HTML here ... <?php $cachefile = "cache/home.html"; // open the cache file "cache/home.html" for writing $fp = fopen($cachefile, 'w'); // save the contents of output buffer to the file fwrite($fp, ob_get_contents()); // close the file fclose($fp); // Send the output to the browser ob_end_flush(); ?>
Don’t hesitate to check out this interesting post if you want to learn more about caching.
If you’re running a WordPress blog, a very handy plugin is Wp Super Cache. Easy to install and configure, Wp Super Cache will create static versions of your WordPress blog pages so it can load quicker.
It’s a must have for all blogs with lots of traffic.
Minify is your friend
The stats above are from a brief walkthrough which shows how easy it is to set up Minify on an existing site. It eliminated 5 HTTP requests and reduced JS/CSS bandwidth by 70%.
To install minify on your website or blog, Download it and unzip the files to a new directory.
Copy the min directory directly into your document root, and you’re done!
Free, easy to install, and extremely powerful, Minify is a real life saver for me and I recommend it to any traffic website owner.
Store media elsewhere
When a site is popular, it tends to use lots of bandwidth. For exemple, a basic blog post with images can eat up to 2GB of bandwidth after making Digg front page, as my highly controversial anti-IE post did a while ago.
To reduce bandwidth usage and consequently make your website load a lot faster, the solution chosen by many highly popular sites is to store media on other servers.
Many services are allowing you to upload your media on their servers. The following list are the most popular sites for storing you website media:
Amazon S3 : Premium service, cost of 15 cents per GB of storage, and 20 cents per GB transfer.
Flickr : Provides both free/limited account and pro account, for $25/year.
Photobucket : provides a free account which let you store up to 10 GB. Paid account cost $25/year.
ImageShack : Storage unlimited, but bandwidth transfer is limited to 100 Mo/hour.
Additional good practices
Above, I have listed my favorite tips to reduce loading time. Those tips are efficient and if you apply them, there’s no doubt that you’ll see a strong loading speed improvement. But there’s many additional tips that you can use to significantly improve your site performance.
For example, I recently heard that you shouldn’t use the @import CSS directive in order to limit extra loading time.
Another thing you should be interested in is how to compress CSS files with PHP, a very nice way to save bandwidth.
Any other tip you’d like to share? Feel free to let me know in a comment.