[Catalyst] recommended/best practice way of serving static files
after authentication?
Tomas Doran
bobtfish at bobtfish.net
Wed Jul 29 00:25:53 GMT 2009
On 28 Jul 2009, at 14:55, Ash Berlin wrote:
>
> On 28 Jul 2009, at 14:42, John SJ Anderson wrote:
>
>>
>> $WORK-mate is working on a Cat app that (among other things) allows
>> authenticated users to download from a set of static files. He's
>> wondering what the best way is to set things up so that the Cat app
>> can handle the authentication/authorization parts of things but then
>> hand the static file serving part off to Apache.
>>
>> Thanks for any help/hints.
>>
>> john.
>
> Largely depends on what webserver you are using. Lighttpd has X-
> LIGHTTPD-Sendfile (or something similarly named) nginx has
> something like X-Accel-Redirect which does the same (and can do
> more.) Both of these tell the webserver to serve static content
> from a file. Hit google for these env vars to find out how they work
>
> There's an apache module which will do the same as the lighttpd one
> http://tn123.ath.cx/mod_xsendfile/ Never used it mind.
Whilst this is all sage advice, remember - DO THE SIMPLEST THING
WHICH COULD POSSIBLY WORK.
Ergo, $c->serve_static_file($c->path_to(qw/ sekrit_files
file1.avi /)); is probably a good bet (From
Catalyst::Plugin::Static::Simple).
Unless you have dozens of concurrent users, all downloading large
files (where large is 10s of Mbs), then just do that - it's easy, it
works, you don't have to think about production vs development, etc.
Cheers
t0m
More information about the Catalyst
mailing list