the blog for developers

8 steps to reduce blog load times from 4sec to below 1sec

I’m obsessed with metrics. I’m obsessed with the number of RSS subscribers. With Google PageRank. Google seems to push faster internet to everyone, with fiber to the home, their own DNS, the page speed plugin and hosting Ajax libraries. As I wanted to get some more Google love, going from PR4 to PR5 and not falling back to PR3, I needed to speed up my blog. But where to start? Isn’t this impossible if you’re not a professional? All of you might have thought about speeding up your website or blog I guess along the same thoughts:

  • Page speed influences pagerank (PR) in the future
  • Firefox experienced a 15% increase in conversion for downloads, by speeding up their landing page recently. For a blog this means better conversion of RSS subscribers and newsletter signups.
  • I was shocked when I saw Google Webmaster Tools show page speeds of 5-15 seconds, still not sure why but urgently needed to get better.
  • Faster pages just feel more professional.
  • Took the opportunity to declutter the blog. Removed external widgets like PostRank I no longer use.

The result of my work is that page loading times are down from 4sec to below 1sec mostly (measured by Pingdom Tools) – Still too slow as I want to get below 0.5sec, but much better than before.

Here are the 8 steps I took to get this amazing improvement:

  1. Inspect your page, e.g. with YSlow, Google Page Speed or Pingdom Tools. Measure, measure, measure. Think about every little Javascript, every image and every CSS. Are they really needed?
  2. Delete all plugins in WordPress you do not really really need – they often inject Javascript or CSS into the page, even if you do not use the plugin in a widget or on the page.
  3. I’ve added a cookieless domain, cmstatic.com to post stuff I do not want to put into the CDN. YSlow suggested this and I’ve seen Stack Overflow use sstatic.net.
  4. Move to a CDN – most of my readers are in the US, my server is in Germany. This leads to slower image downloads and especially latency, or startup times before the first byte arrives. I’ve chosen Cloudfront for now because it was easy to setup and I had an Amazon account. I’m using CloudBerry for uploads, it’s free in the basic version and just works. I might move to a cheaper CDN that better supports (SimpleCDN is full!) GZIP and expire headers. I’ve added a domain for my CDN usage at cdn.cmstatic.com which adds some flexibility.
  5. I’ve removed merciless Javascript from WordPress (JQuery was twice on the page), I’ve minified JS and packaged all CSS into one CSS file. This results in less DNS lookups, less http connections and smaller files and overall reduces page loading times significantly.
  6. Added expire header in the far future with a version URL scheme ( /version/images/ … e.g. /1/images), so everything is cached in the browser. I can increase the version number with new assets. Expire headers are easy to do with Apache on cmstatic.com by adding .htaccess, more difficult with Cloudfront (see above, a reason to possibly move to another CDN). I also removed ETags when possible so the .htaccess looks like this:
    ExpiresActive On
    ExpiresDefault "access plus 1 year"
    FileETag None
    
  7. Added GZIP where possible, was easier with Apache than Cloudfront:
    <Files *.js>
    SetOutputFilter DEFLATE
    </Files>
    
  8. I’ve reduced the number of posts on the page. Now there are only 3 posts on the start page. I might move to summaries, as they are shorter, have less images, faster download.

Overall I’m pleased with the results. Especially as the page really feels much faster to me, not only the metrics are better. So what’s left to do: External images and JS, like tweetmeme, quantcast and Google Analytics still are slow – something I need to solve.

I had some fun during all of this and learned a great deal about CDNs, so I suggest you do the same.

About the author

stephan Stephan Schmidt has been working with internet technologies for the last 20 years. He was head of development, consultant and CTO and is a speaker, author and blog writer. He specializes in organizing and optimizing software development helping companies by increasing productivity with lean software development and agile methodologies. Want to know more? All views are only his own. You can find him on Google +

You can leave a Reply here. Of course, you should follow me on twitter here.

You can share this post!
Do you want to tell others about this article? Use the social bookmark icons to submit this artice to the service of your choice. Thanks.

10 Tweets

Leave a reply.

Comments

Thank you very much, interesting stuff here!

Unfortunately its a bit unclear how exactly you manage the different versions of your static files (js/css) at cloudfront.
Do you have to change the includes of your blog manually?

@andy: For now, yes by hand.

I wrote a function for WordPress

    function cdnbase() {
        echo "http://cdn.cmstatic.com/1";
     }

which is used throughout the template, so I only need to change this URL after playing with the site. Then when finished, add infinity expire headers.

I plan to read this from a plugin page in the future, and autosync from the local directory to S3/Cloudfront.

Can you tell out of which point you got the biggest performance boost?

@Oliver: From Pingdom Tools the CDN, from Firebug/Network most probably the DNS lookups.

9. load javascripts you don’t need immediately asyncronously or on demand. e.g. if you’re using Google Analytics, move to the asyncronous Google Analytics (http://googlecode.blogspot.com/2009/12/google-analytics-launches-asynchronous.html)

10. use CSS sprites to decrease the amount of HTTP requests

11. caching. everywhere ;-) e.g. static resources on server side (most CMS do this out of the box)

and to be precise: page speed will not influence page rank (PR) in the future – it will affect your ranking. page rank is a metrics based on your inlinks and is one factor (among many others) to determine your position on the search engine results page (SERP)

and one more thing: if you happen to use wicket for your webapps, there is some interface speed up advice over there: http://techblog.molindo.at/2008/08/wicket-interface-speed-up-merging-resources-for-fewer-http-requests.html

@Michael: Care to elaborate? I thought PageRank determined the position on the search engine results page primarily. If it doesn’t, what is PageRank good for?

@Michael: I might add I already used WP-SuperCache for static pages, a MUST as you’ve said.

@stephan PageRank is an algorithm to analyse the links pointing to a specific page. Google originally counted all links pointing to a page as a vote for the page. it is among other metrics a factor to determine the position on the SERP. other factors are among many others e.g. relevancy of the content, domain age, language, location of the server (e.g. for regional searches), time (e.g. for news) and now new: page speed. I still believe, as you said, that PageRank or more importantly the links pointing to your page _are_ the most important factor to get a good ranking.

So page speed will affect the position of your page in the SERPs but won’t have a direct impact on your PageRank which as said only analyses the links pointing to your site. there may be an indirect effect however, as your page might get more popular if it’s faster and people then link to it more often.

Actually I only wrote the comment to say that

“Page speed influences pagerank (PR) in the future” should be put to something like “Page speed influences the search engine rankings in the future” :-)

@Michael: Thanks for the explanation.

Joe

Any luck with getting Google Analytics to stop using cookies with the CDN?

Leave a Reply

What people wrote somewhere else:

My new blog post: 8 steps to reduce blog load times from 4sec to below 1sec http://bit.ly/azxHwO

This comment was originally posted on Twitter

Stephan Schmidt: 8 steps to reduce blog load times from 4sec to below 1sec http://bit.ly/aBqb9S

This comment was originally posted on Twitter

very nice, thanks! RT @codemonkeyism: My new blog post: 8 steps to reduce blog load times from 4sec to below 1sec http://bit.ly/azxHwO

This comment was originally posted on Twitter

My new blog post: 8 steps to reduce blog load times from 4sec to below 1sec http://bit.ly/azxHwO /via @codemonkeyism my evening read

This comment was originally posted on Twitter

codemonkeyism: My new blog post: 8 steps to reduce blog load times from 4sec to below 1sec http://bit.ly/azxHwO http://url4.eu/2fURU

This comment was originally posted on Twitter

RT @codemonkeyism: My new blog post: 8 steps to reduce blog load times from 4sec to below 1sec http://bit.ly/azxHwO

This comment was originally posted on Twitter

Code Monkeyism: 8 steps to reduce blog load…: http://bit.ly/a79eHn

This comment was originally posted on Twitter

RT @codemonkeyism: My new blog post: 8 steps to reduce blog load times from 4sec to below 1sec http://bit.ly/azxHwO

This comment was originally posted on Twitter

RT @codemonkeyism: My new blog post: 8 steps to reduce blog load times from 4sec to below 1sec http://bit.ly/azxHwO

This comment was originally posted on Twitter

Interesting blog entry by @codemonkeyism about reducing load time for a WP blog: http://bit.ly/921Gy2

This comment was originally posted on Twitter

Additional comments powered by BackType

Guide to CodeMonkeyism

Over the last 4 years I wrote many articles on this blog. To make it easier for you to find the relevant ones, I've organized them into topics.

Top 10

6 reasons why my VC funded startup did fail

Go Ahead: Next Generation Java Programming Style

Java Interview questions: Write a String Reverser

The dark side of NoSQL

7 Bad Signs not to Work for a Software Company or Startup

Is Java dead?

Scala vs. Clojure

Never, never, never use String in Java

No future for functional programming in 2008 – Scala, F# and Nu

Clojure vs Scala, Part 2

Java Developer

Is Java Dead?

Go Ahead: Next Generation Java Programming Style

Be careful with magical code

All variables in Java must be final

Never, never, never use String in Java

Bending Java: More readable code with methods that do nothing?

NoSQL Guy

NoSQL: The Dawn of Polyglot Persistence

The dark side of NoSQL

Essential storage tradeoff: Simple Reads vs. Simple Writes

Sharding destroys the goals of your relational database

The unholy legacy of databases

Startup/CTO

Development Dream Teams

6 reasons why my VC funded startup did fail

American vs. European style of Software Development

12 Things to Reduce Your Lead Time and Time to Market

The high cost of overhead when working in parallel

Essential storage tradeoff: Simple Reads vs. Simple Writes

Job Seeker

Another Good (Java) Interview Question

7 Bad Signs not to Work for a Software Company or Startup

Java Interview questions: Write a String Reverser (and use Recursion!)

Java Interview questions: Multiple Inheritance

As a Manager: What I value in developers

Top 10 Tips (+1) to Get a Pay Raise

Agilist

What Developers Need to Know About Agile

5 Practices Better to Change in Your Scrum Implementation

Scrum is not about engineering practices

ScrumMaster and ZenMaster: The joke of certification

What is Trans-Scrum?