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.
More recent articles
- First impressions of the new Amazon Nova LLMs (via a new llm-bedrock plugin) - 4th December 2024
- Storing times for human events - 27th November 2024
- Ask questions of SQLite databases and CSV/JSON files in your terminal - 25th November 2024