close
今天才知道原來 lighttpd or ngix 都有 X-sendfile 這一類的好東西阿!!!
用這一類手法可以有複雜的認證/檢查, 然後檔案還可以送得又快又好 XD
用php吐靜態檔案 跟用 lighttpd吐靜態檔案的效率實在差太多了啊 XD
有興趣的人可以看以下兩個link or google找更多資料:
http://blog.lighttpd.net/articles/2006/07/02/x-sendfile
http://trac.lighttpd.net/trac/wiki/Docs%3AModFastCGI
以lighttpd為例, 用法如下:
lighttpd.conf fastcgi部分加上:
"allow-x-send-file" => "enable"
sample code:
$path="/home/data/ooxx";
$file="actual_file.zip";
$file_to_download='filename.zip';
//X-Sendfile sample: X-Sendfile (lighttpd 1.5+) or X-LIGHTTPD-send-file (
header("Content-Type: Text/Plain");
header("Content-Length: ".filesize("$path/$file"));
header( "Content-Disposition: attachment; filename=\"" . $file_to_download . '"' );
if($_SERVER['SERVER_SOFTWARE']<'lighttpd/1.5')
header("X-LIGHTTPD-send-file: $path/$file");
else
header("X-Sendfile: $path/$file");
?>
簡單好用, 一看就懂吧 XD
用這一類手法可以有複雜的認證/檢查, 然後檔案還可以送得又快又好 XD
用php吐靜態檔案 跟用 lighttpd吐靜態檔案的效率實在差太多了啊 XD
有興趣的人可以看以下兩個link or google找更多資料:
http://blog.lighttpd.net/articles/2006/07/02/x-sendfile
http://trac.lighttpd.net/trac/wiki/Docs%3AModFastCGI
以lighttpd為例, 用法如下:
lighttpd.conf fastcgi部分加上:
"allow-x-send-file" => "enable"
sample code:
$path="/home/data/ooxx";
$file="actual_file.zip";
$file_to_download='filename.zip';
//X-Sendfile sample: X-Sendfile (lighttpd 1.5+) or X-LIGHTTPD-send-file (
header("Content-Length: ".filesize("$path/$file"));
header( "Content-Disposition: attachment; filename=\"" . $file_to_download . '"' );
if($_SERVER['SERVER_SOFTWARE']<'lighttpd/1.5')
header("X-LIGHTTPD-send-file: $path/$file");
else
header("X-Sendfile: $path/$file");
?>
簡單好用, 一看就懂吧 XD
全站熱搜
留言列表