Project

General

Profile

X-LIGHTTPD-send-file » History » Revision 8

Revision 7 (glen, 2014-01-22 11:30) → Revision 8/9 (gstrauss, 2016-09-11 00:29)

h1. X-sendfile 

 {{>toc}} 

 Option to let lighty handle large file-downloads instead of PHP. 
 * X-Sendfile, X-LIGHTTPD-send-file (old alias) 
 * X-Sendfile2 (available since 1.4.24) 

 h1. Description 

 Let lighty handle downloads of large files instead of using PHP. 

 see [[Docs_ModFastCGI#X-Sendfile|mod_fastcgi]] page for details 

 h1. HowTo 

 Your typicall FastCGI setup + "allow-x-send-file" => "enable" 

 <pre> 
 fastcgi.server = { 
    ".php" => { 
       "127.0.0.1" => { 
           # .... 
           "allow-x-send-file" => "enable" 
       } 
    } 
 } 
 </pre> 

 Tell PHP not to handle the file download, instead set up a header like this: 

 <pre> 
 <?php 
 /** 
  * lighttpd's feature of X-Sendfile explained. 
  *  
  * @author Björn Schotte <schotte@mayflower.de> 
  */ 
 $file_on_harddisk = "/data/vhosts/bjoern/htdocs/acbd18db4cc2f85cedef654fccc4a4d8download.tar.gz"; 
 $file_to_download = "download.tar.gz"; 
         header( "Content-Disposition: attachment; filename=\"" . $file_to_download . '"' ); 
         Header( "X-LIGHTTPD-send-file: " . $file_on_harddisk); 
 ?> 
 </pre> 

 h1. Notes 

 Lighttpd 1.4.40 and later 1.4.20 does not support Range requests from client Range-requests with X-LIGHTTPD-send-file. 
 Range-request support in conjunction lighttpd 1.5 with backend X-LIGHTTPD-send-file response. X-Sendfile is unknown. 

 h1. External links 

 * http://blog.lighttpd.net/articles/2006/07/02/x-sendfile 
 * http://blog.thinkphp.de/archives/136-Make-the-download-of-large-files-with-PHP-and-lighty-very-easy.html