Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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.


    $|=$_="1g2i1u1l2i4e2n0k",map{print"\7",chop;select$,,$,,$,,$_/7}m{..}g

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2019-12-11 13:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?