Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Caching images from RDBMS

by tadman (Prior)
on Aug 08, 2002 at 10:41 UTC ( #188550=note: print w/replies, xml ) Need Help??

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.

Replies are listed 'Best First'.
Re: Re: Caching images from RDBMS
by giulienk (Curate) on Aug 08, 2002 at 10:54 UTC
    Yeah, i always use placeholders. In this particular case i didn't cause the regexp is already purging everything that's undesired.

    What i didn't explain in my original post is the image name is unique and changes with date. Here is the sub that generates the URL

    sub image_path { my ($id, $image) = @_; my ($mydate) = $dbh->selectrow_array( "SELECT time FROM offerte WHERE id=$id" ); return "/images.cgi/${id}_${image}_${mydate}.jpg"; }

    As you can see i already have a time field :).

    Thanks for the suggestions.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://188550]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2020-11-30 07:19 GMT
Find Nodes?
    Voting Booth?

    No recent polls found