[Catalyst] Question on serving files

Chris hutchinson.chris at gmail.com
Sun Feb 18 23:14:54 GMT 2007


>
> You can set the header information to give mime hints to the browser:
>
>       $c->res->headers->content_type('application/octet-stream');
>         $c->res->headers->content_length( $stat->size );
>         $c->res->headers->last_modified( $stat->mtime );
>         $c->response->headers->header(
>             'Content-disposition:' => "attachment; filename=$filename" );
>         $c->res->headers->expires( time() );
>         $c->res->headers->header( 'Pragma'        => 'no-cache' );
>         $c->res->headers->header( 'Cache-Control' => 'no-cache' );
>
>

Interestingly, if you set 'no-cache' on file downloads over an SSL
(https) connection where IE has a mime-handler defined (word/xls/pdf),
will throw spurious errors about being unable to cache the file, even
when trying to 'save target as'.

This isn't a catalyst issue, but an IE 'feature'- might be useful to
know before it bites, though.

- Chris



More information about the Catalyst mailing list