giulienk has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a modperl application (running under Apache::Registry) where i decided to serve images from the DB for various reasons. I got a simple CGI script to serve images, it looks like this:
use strict; use lib '/path/to/my/lib/'; use MyDBI; #export $dbh use CGI qw(header path_info); my ($id, $image) = path_info() =~ m{(\d+)_((?:image|thumb|mini)[1-3])(_.+)?\.jpe?g$} +i; exit unless $id and $image; my ($file) = $dbh->selectrow_array("SELECT $image from offerte WHERE +id=$id"); exit unless $file; print header(-type => 'image/jpeg', -Content_length => length $file), +$file;
This is working fine except for caching. Browsers keeps on asking conditional GETs sending If-Modified-Since fields.
As the filenames changes if the image changes all i want to do is just replying a 304 header if i receive a conditional GET.
Can i do it with a simple script like mine, do i have to use Apache API or do i have to install an Apache handler?