Sun, 10 Oct 2004

Blosxom Static Rendering with Writeback Plugin

This site runs on a poor little Pentium MMX 200, so the performance of Blosxom, the software that drives the site, isn't very good. Luckily, Blosxom has a static rendering mode which allows Apache to serve flat html pages. In order to use the writeback plugin, though, POST requests to trackback an entry or post a comment must be handled directly by Blosxom.

So I set up Blosxom in a hybrid manner where new entries are rendered statically every 15 minutes, and the entire site is re-rendered every two hours to bring in comments and trackbacks to the flat pages. All POST requests are handled by Blosxom, as are requests for pages which haven't been pre-generated yet. I can also temporarily disable static rendering if I want to preview a new post without it showing up on the index pages.

My crontab

*/15 * * * * test -f /usr/local/www/ && /usr/lib/cgi-bin/blosxom -password=xxxxxxxxxxx -quiet=1

# regenerate all pages to pull in comments
15 */2 * * * test -f /usr/local/www/ && /usr/lib/cgi-bin/blosxom -password=xxxxxxxxxxx -all=1 -quiet=1

I can remove the .gen file and preview an entry by going directly to the entry's URL.

Apache Rewrite Rules

RewriteCond %{QUERY_STRING} ^$
RewriteCond %{DOCUMENT_ROOT}/static/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/static/$1 -d
RewriteRule ^/blog(/?.*)$ /static/$1

I test for an empty query string so that Blosxom will handle the request when I want to enable autotrack. Also, if I want to preview changes to an entry that has already been generated, I can just tack something on to the query string.

It looks like this is similar to Rael's setup, but he only serves the statically rendered index pages directly from Apache and has Blosxom handle all individual entry pages.

tech | Comments | Permanent Link

The state is that great fiction by which everyone tries to live at the expense of everyone else. - Frederic Bastiat