[Catalyst] Serve blob files into src="" type tags

Matt S Trout dbix-class at trout.me.uk
Sun Mar 12 14:29:18 CET 2006


apv wrote:
> On Saturday, March 11, 2006, at 01:31  PM, A. Pagaltzis wrote:
>> * apv <apv at sedition.com> [2006-03-11 19:15]:
>>> For 1. I know the file system serves them better but there are
>>> (as well you know) many reasons why a DB can be superior. And
>>> I'm planning on writing them out to disk the same way I'm going
>>> to write out the regular files to disk (talked about doing this
>>> a couple months ago). They're going to be in the DB for
>>> better/easier/integral management (modeling).
>> As a suggestion, and just in case you hadn’t thought of this,
>> what I do whenever I need to do something like that is put
>> filenames (or paths) in a table column, instead of making it a
>> BLOB. Or maybe I use the row ID as the filename, internally. Or
>> something like that. In any case, the data lives in the
>> filesystem (usually in a flat directory) and only the metadata is
>> in the database.
> I definitely considered it. The reason I'm moving away from it
> is I want a "site" to be its database + its Catalyst app. Not the
> database + 50 assorted CSS and JS files + several hundred or
> even several thousands of images which may have been twiddled,
> moved, and renamed manually without letting the database
> know that the record it pointed to is now hopelessly "corrupt."

I've ended up making the same call on a couple of occasions, and it's worked 
out pretty well. *but* there's one thing you really have to take account of - 
make sure the code the serves the BLOBs understands a HEAD request and sends 
an appropriate Last-Modified-Time (and pref. can deal with If-Modified-Since 
and friends as well). That way when you need to scale you can stick a reverse 
proxy in front of the app, and presto, the files *are* being served off disk - 
out of the proxy cache :)

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list