Is it possible to configure lighttpd so that a request for a file succeeds if the file exists, but is handled and redirected, for example to a cgi script, if the file does not exist?
What I'm trying to achieve is having a set of image files on disk which are generated by a script and served directly. On a request, if the file does not exist, the script will generate the image and save it to disk (for future requests) and then either serve the image directly or redirect back to the same URL which will this time succeed. I'm essentially caching the generated output on disk.
I currently have a prototype in which the script always handles the request, reading and echoing the file if it exists, but I'd rather save the overhead and have lighttpd serve it directly if possible.