I’ve been having a hard time making up my mind about whether I think baked or fried is better for a weblog (a baked page is a static file, like Movable Type/Blogger/Radio serve up, a fried page is build from the database (or text files, or whathaveyou) when it is requested, like b2 or blosxom). Thinking about an individual entry archive page getting heavily linked, or the main page when I forget to update for several days, so it’s not changing, rebuilding it for every page view seems like a waste of time and trouble. However, making a tiny change in a template and having to rebuild 490-some static files makes a fried page look pretty good.
While browsing through Rasmus’s Tips and Tricks slides from his talk at PHPCon, I think I found my answer (on page 25 of the accursed PDF file), in what he calls “funky caching.” It works like this: you redirect 404 errors to a PHP script, which looks at the requested URL, decides whether it should actually exist, and if it should it builds the file from the database, saves it to the filesystem, and then returns the page to whoever requested it. Next time that URL is requested, the static file will be served.
What would that mean for a weblog? If a post gets slashdotted or scripting.commed, you’re just serving up static files, not having to run to your database every time a request comes in. The only time you would need to rebuild an entry page would be when someone adds a comment, or when you change the entry or the template. How do you rebuild after a template change? Unlike the Movable Type system of waiting while hundreds of static pages are built, hoping that your cheap shared host’s reaper doesn’t shut the script down, you just delete all the files. If you’re doing a redesign, making dozens of changes, you only need to rebuild the pages you are actually checking, by deleting them and then viewing them once in your browser. Everything else can wait until someone wants the page (and chances are it will be a search engine robot, which can just wait patiently while its pages are fried). Whether or not it’s really a good, efficient system, I love the idea of rebuilding the site by just deleting all the files and then walking away.