On Mon, Mar 23, 2009 at 10:07:00PM -0400, Vincent Veselosky wrote: > > 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.
Doesn't $m->clear_buffer(); take care of that? > * Always explicitly set the content-type header in the component (before you > flush any buffers!). I set the content-type after clear_buffer() and it works fine. It seems more logical to me, no? > * 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.) ... or have a $r->path_info with the correct extension. That way you can keep your component naming scheme (.md, .mhtml, etc.) and have the client think it's downloading a real file. /video.md/dummy/path/to/file.mp4 > Does anyone else have some handy tips? I would like to hear how others are > doing this too. My tip would be to disable mod_deflate when serving video to a flash player such as FlowPlayer. Even if your mod_deflate is configured to compress only text/html output, it won't notice the content-type change done inside your component and will only rely on the component's extension to deduce its content-type. So unless your mason component has an .mp4 extension you can do: $r->subprocess_env('no-gzip' => 1); $r->subprocess_env('dont-vary' => 1); and FlowPlayer will be happy. Cheers, ------------------------------------------------------------------------------ _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users