November 24, 2009
This is speed!

My personal site is composed by a single html page. This page has some parts that are dynamic (weather and ‘latest from my log’).

Updates of theese parts are really rare so I couldn’t find a real need to get this page to be generated at every request. On the other side I didn’t want to loose these little dynamic parts.

The only way to achieve this result was to generate html page on periodical basis.

I’m a rubyst so the only way to do it was with a little ruby script. It runs every 5 minutes (a good trade off between ‘freshness’ and ‘load’) because the most updating part is ‘latest from my log’ and I update it quite rarely in a day.

The script is really simple, it fetches weather data, fetches recents post from this tumblog, generates html page, switches the old ‘index.html’ with the new one and minimizes css.

I’m really curious about performance in many things I do, this script isn’t an exception infact I output how much time every generation takes, but honestly I never noticed how fast it is! :)

Fetching/Parsing weather information -> 0.06 seconds

Fetching/Parsing rss feed of this tumblog -> 0.09 seconds

Generate the new index.html -> less than 0.01 seconds

Switch the old index.html and the new one -> less than 0.01 seconds

Minifying css -> less than 0.01 seconds

So every page generation of my personal site (with dynamic parts) takes less than 0.2 seconds of downtime!!!

I think it’s worth :P