Why this site is crazy fast

Friday, May 1st, 2009 at 10:29

I love web performence pretty much like 15 years likes to trim their mopeds. (At least they did like to before web). While the blog definitely scaled better over at wordpress.com, I believe it performs better on my ubuntu server powered laptop at home, since it only powers one instead of gazillions of blogs. Also I was surprised I needed to pay $15/year just to be able to customize the css on wp.com. So here follows a short description of how I took full control over the stack.

The bad parts of making the switch was that I needed to bloat my precious server with mysql and php ;)  I might move to Zine when it gets a little more mature but for now I really don’t care. Anyway. Basicly it’s the wp-super-cache plugin that makes the most from a performence perspective. It’s pretty much staticgenerator for wordpress, it generates static html files from the blog. But instead of letting the proxypassed apache serve those html files, I of course serve them with nginx. Not only is it faster, it let’s me fine tune the config in ways apache doesn’t, beacuse of it’s support for if statements. That makes it easy to serve the cached created files with expire headers.

if (-f $document_root/$supercache_file) {
  rewrite ^(.*)$ $supercache_file;
  expires 1h;
  break;
}

Obvious overkill you might think. But fact is I don’t post new posts very often, so why should one need to download the same html twice? wp-super-cache also generates gzip’d files, so you don’t need to waste cpu on gziping the same html over and over again. With gzip_static in nginx this is possible. If you request /foo/index.html with Accept-Encoding: gzip and have gzip_static on, nginx automaticly checks if there is a file /foo/index.html.gz and serves it.

Does all this makes this site diggproof? I don’t know for sure. I guess it all depends on my bandwidth (10 mbit up should be enough) and also if many people makes comments on the same time. Chances are pretty low I will get that much traffic anyway. But a fast site makes visitors happy anyway.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>