Categories
josephscott

PHP, But Only When Needed

There are times when you only want to have your PHP scripts run when certain conditions have (or haven’t) been met. This technique is often used for caching. A real life example of this is discussed in Serving rendered images at the speed of light. The gist of the story is that a PHP script is used to generate thumbnails of images, but it only needs to be called when a thumbnail doesn’t already exist.

The described solution involved making use of Apache‘s mod_rewrite, so this isn’t a purely PHP solution. If you aren’t already familiar with mod_rewrite that is okay (I’ve used and it is still quite confusing at times), the author covers each step one at a time.