On Mon, 23 Mar 2009, Mark Copper wrote:

> I know it's inefficient, and once I saw where Dave Rolsky mentioned that
> he used a separate handler to serve images, but for me Mason was very handy
> for serving scaled images.  A dhandler in the thumb directory could
> serve images /docroot/thumb/pic.jpeg?scale=100&quality=75 scaled from
> images stored in an images directory and m->cache made saving the scaled
> images soo easy.  I need to replace it for other reasons, but it sure was a
> nice way to get started.

My name was invoked so ...

The way I generally approach the problem of serving binary data that needs 
some dynamic generation is simple. I generate the data in the current 
request, write it to disk in a location servable by the static web server, 
and include a proper URI in the response.

For an image that means the image src tag, for a pdf or zip file it might 
be a redirect.

This lets you cache things just fine, and you don't eat up memory jamming 
things into your cache, bloating your persistent Perl interpreter.

The big issue is security. If the thing you're serving has to be access 
controlled, it's more of a problem.

One possible solution is to put it in a subdirectory that's an SHA1 digest 
of some server side secret and some part of the content (the filename 
would make sense).

This is, technically, security by obscurity, but realistically it's not 
guessable.

If that's not good enough you might have to serve it from the web 
application side. If you're running under mod_perl, you could use a 
PerlAuthzHandler to do the auth and let Apache's built-in static file 
handling serve the content.

Otherwise under mod_perl you can use $r->send_fd/sendfile.

The worst thing you can do is generate/read the whole thing into memory 
and then spit it out.


-dave

/*============================================================
http://VegGuide.org               http://blog.urth.org
Your guide to all that's veg      House Absolute(ly Pointless)
============================================================*/

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to