Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

Funky caching explained

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.

View blog reactions

Next: Usability Views

Previous: High end CMS vendors in trouble

4 comments

  1. Thanks for the info... I'll be looking more into this :)

    Jon - 18th November 2002 11:01 - #

  2. This funky 404 caching technique utilised on those websites "running a CMS costing hundreds of thousands of pounds" you mentioned before. If only they could get the url's right.

    Albert - 26th November 2002 19:55 - #

  3. Why bother with deleting a static file, manually for that matter? For PhotoStack I am using a method where I look at the modified times of files (templates, albums, and the txt databses) and compare them to see if a rebuild of that page is necessary. You could use the same except checking the last time an entry was modified (in MySQL) and comparing that time to the last time the page was modified then creating the page if necessary. It would be a perfect method taking both "fried" and "baked into consideration. Sort of baked, sort of fried... perhaps grilled :-)

    Noel D. Jackson - 22nd June 2003 08:12 - #

  4. yep

    tim - 25th February 2004 22:03 - #

Comments are closed.

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

A django site