SPUG:CGI header question

Aaron Salo aaron at activox.com
Thu Jun 19 11:26:01 CDT 2003


At 08:52 AM 6/19/2003 -0700, you wrote:
>	I'm working on a project where I'm storing media (photos, sound files) in a
>database and serving them through a perl script.  My image tags look like
><img src='Photo.pl?PhotoID=14232'>, which works fine.  What I'm looking for
>advice on is that since this is a perl script browsers wont cache the
>result, so it wants to download the images again weither it is new or not.

Hi Peter,

<rant>
files belong in the *file system*
data belongs in the *database*
</rant>

sorry, one of my pet peeves. forgive me in advance if this is one of those
projects where these decisions were made for you and you're just trying to
minimize the damage.

seriously, if you store a pointer in the database to the image file, and
leave the image file in the file system, and then roll up the IMG SRC tag
in the page by deriving the path to the image from the db pointer, all
normal browser caching mechanisms will perform as intended, thus averting
the problem you're trying to correct. using your current method 

<img src='Photo.pl?PhotoID=14232'>

the browser cannot cache the stuff as you correctly point out, but by
putting those images in the file system and rolling up those tags normally
in your CGI output page

<img src='/path/to/image/from/the/database/call/14232.jpg'>

this is no longer a problem.

it has always seemed odd to me that people wish to store images in a
database as blobs. why would you go through all the work to store, kick
headers, emit streams of binary and contribute to the database equivalent
of global warming (increased backup times, more overhead, etc) by bloating
your tables with binary storage, when you can just keep it in the
filesystem and store the information necessary to retrieve it from there?
can someone tell me where I'm missing the point here??

hth
aaron






More information about the spug-list mailing list