On Mon, Mar 23, 2009 at 10:07:00PM -0400, Vincent Veselosky wrote:
> 
>    On Mon, Mar 23, 2009 at 7:48 PM, J?r?me Et?v?
>    <[1]jerome.et...@gmail.com> wrote:
> 
>      Hi Vincent,
>      Why can it be wrong to serve binary content ? How do you do for
>      instance when you want to dynamically generate an image or any kind
>      of
>      binary document based on the user's data ?
>      Cheers !
>      J
> 
>    I wouldn't say it is "wrong" necessarily, only that it is often not
>    the best solution. Some disadvantages:
>    * performance: Apache will serve binary content from the file system
>    with better response times
>    * memory: serving with a mod_perl process could use 10-100MB more RAM
>    than Apache optimized for static files (and since binaries are often
>    larger than text files, the process will be held longer)
>    * pain: one slip in the code can cause your binary to be corrupted,
>    and this can be hard to debug.
>    I find it is often more efficient to pre-generate binaries using an
>    offline script. That said, I have used Mason to serve binaries,
>    specifically CAPTCHA images which need to be both randomly generated
>    and associated with a particular form submission for checking. It's
>    not always wrong! :)
>    Some rules to follow in components that serve binary data:
>    * Always use the inherit => undef flag. Any text sent from any
>    component in the chain will corrupt your binary, and this is the only
>    way to ensure that never happens.
>    * Always explicitly set the content-type header in the component
>    (before you flush any buffers!).
>    * Name the component with an extension appropriate to the
>    content-type. If it generates pdf files, name it something.pdf, and
>    modify your apache configuration specially for that file. (This one
>    may be considered controversial, but I find it saves lots of pain at
>    the client side, and I strongly recommend it.)
>    Does anyone else have some handy tips? I would like to hear how others
>    are doing this too.
>    --
>    -Vince Veselosky

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.

Mark

------------------------------------------------------------------------------
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