Simon Willison’s Weblog

Subscribe

Funky caching explained

16th November 2002

I didn’t take much notice of “funky caching” while reading through Rasmus Lerdorf’s PHP tips and tricks presentation—I saw that it was talking about using custom 404 pages to serve up dynamic content depending on the URL and wrote it off as a hack that, while useful, was fundamentally flawed in that it would add an error log entry whenever a page was served.

It seems I was mistaken. Phil Ringnalda has explained the concept in more detail, and it’s actually a very clever angle on the caching problem. Rather than building content in advanced (the “baked” method, used by Moveable Type) or generating the page dynamically each time (the “fried” method, used by my weblog) you set up a custom 404 script which decides whether or not the requested content should exist when it is called. If the content is meant to be there, it creates the content, serves it up and saves it to the file system (so future requests will get the file rather than a 404). To regenerate content you just delete the static file and wait for someone to request it, at which point it will be rebuilt by the 404 script. Clever stuff.

This is Funky caching explained by Simon Willison, posted on 16th November 2002.

Next: Usability Views

Previous: High end CMS vendors in trouble

Previously hosted at http://simon.incutio.com/archive/2002/11/16/funkyCachingExplained