[Catalyst] serving static content from one controller?

Ash Berlin ash_cpan at firemirror.com
Fri Oct 5 08:12:16 GMT 2007

Jonathan Rockway wrote:
> Dustin Suchter wrote:
>> I've looked into "Static::Simple", but I can't find a good
>> manual/tutorial on it. I've tried to guess at how to use it but I
>> pretty much didn't get anywhere.
> This is probably not the best idea.  It would be better for your
> Catalyst app to inform your web server as to what static page to serve. 
> perlbal calls this an "internal redirect", and lighttpd calls it
> "X-SendFile".  Please look into those; all your cat app will have to do
> is send an HTTP header with the name of the file, and the web server
> will take care of the rest.
> This has come up before, I think, so grep the list archives for more detail.
> Failing that, you can always set $c->res->body to a filehandle:
>    sub send_static :Private {
>       my ($self, $c, $filename) = @_;
>       open my $fh, '<', $filename or die "failed to open $filename: $!";
>       $c->res->body($fh);
>       $c->detach;
>    }
> Hopefully the internal redirects will work out for you, though.  Good luck.
> Regards,
> Jonathan Rockway

Another option instead of using X-SendFile for lighttpd is to do as I
describe in http://perlitist.com/articles/catalyst-with-lighttpd

If you are using apache and want to achieve something similar with
static files let me know and I can show you the config you'd need to get
the same affect (Apache to serve the static stuff)


More information about the Catalyst mailing list