http://qs321.pair.com?node_id=188550


in reply to Caching images from RDBMS

As in Caching Web Pages, you probably want to look in to using Squid Cache to do the dirty work for you. Barring that, maybe you could store a date field in the DB and check if you need to resend. You can send your own "304" header using CGI, after all.

By the way, you should probably be using placeholders, like this:
my ($file) = $dbh->selectrow_array("SELECT $image FROM offerte WHERE id=?", {}, $id);
It may not make a difference in your particular case, since you are using numeric data, but I'd argue it should be done out of principle. If you always use them, you don't have problems with mistyped data.