mod_xsendfile
Overview
mod_xsendfile module handles X-SENDFILE headers registered by the original output handler.
If the module finds X-SENDFILE header, it discards the output and instead sends the file specified by that header using Ape core functions.
It is useful to:
- Speed-up statics downloading for CMS (by avoiding reading/sending file via script engine)
- Check user ability to download (e.g. checking quota in database)
- Record downloads statistics (advanced download counter)
- Flexible configuration of 'Expires' header
Quick start
Having mod_xsendfile enabled, you may use the following code to initiate downloading (not processing) of hello.txt
<?php
//set proper Content-Type
header('Content-Type: plain/text');
//force download box with the filename hello.txt
header('Content-Disposition: attachment;filename=hello.txt');
//file is located at c:/home/username/hello.txt
header('X-Sendfile: c:/home/username/hello.txt');
?>
Related articles and topics
Directives
XSendFile
When On, enables processing of X-SENDFILE header.
Syntax
XSendFile On|Off
Description
XSendFile directive sends the file specified in X-SENDFILE header instead of the handler output.
If the response lacks the X-SENDFILE header, nothing will happen.
Example
<Files out.php>
XSendFile On
</Files>
XSendFileAllowAbove
Allows or disallows sending files above Request path.
Syntax
XSendFileAllowAbove On|Off
Description
XSendFileAllowAbove directive, when set, allows sending
files not below the path of the Request (this refers to the request URI not the translated path).
Example
<Location /out>
XSendFileAllowAbove On
XSendFile On
</Location>
|