We are trying to use mod_xsendfile with Apache to effectively manage large file downloads (> 1 GB). After installation, the configuration is as follows:
<IfModule mod_xsendfile.c>
<Directory "/abs_path/to/dl">
XSendFile on
XSendFilePath /abs_path/to/files_dir
</Directory>
</IfModule>
The download script does not represent anything, it simply checks for the presence of the file to download and sets the headers according to the documentation, for example:
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
header("X-Sendfile: " . $file);
Continuous downloads work great with any user agent we tested with, and HTTP-Range works fine with everyone except Firefox (tested versions 27 and 28). Firefox may pause the download, but the resume is interrupted every time.
These are the http headers recorded with the Live HTTP Header Extension:
Bootstrap:
http://www.oursite.com/dl/test-xs.php?ID=TestFileID
GET /dl/test-xs.php?ID=TestFileID HTTP/1.1
Host: www.oursite.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: some cookie string...
Connection: keep-alive
HTTP/1.1 200 OK
Date: Tue, 25 Mar 2014 10:22:46 GMT
Server: Apache
X-Powered-By: PHP/5.3.28
Content-Disposition: attachment; filename="TestFile.ext"
Last-Modified: Sun, 02 Mar 2014 18:20:36 GMT
Content-Length: 84406272
Connection: close
Content-Type: application/octet-stream
... and when Firefox tries to resume:
http://www.oursite.com/dl/test-xs.php?ID=TestFileID
GET /dl/test-xs.php?ID=TestFileID HTTP/1.1
Host: www.oursite.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: same cookie string...
Connection: keep-alive
Range: bytes=11238434-
If-Unmodified-Since: Sun, 02 Mar 2014 18:20:36 GMT
... the server returns 404
HTTP/1.1 404 Not Found
Date: Tue, 25 Mar 2014 10:23:03 GMT
Server: Apache
X-Powered-By: PHP/5.3.28, PHP/5.3.28
Content-Disposition: attachment; filename="TestFile.ext"
X-Sendfile: /abs_path/to/files_dir/TestFile.ext
X-Pingback: http://www.oursite.com/xmlrpc.php
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
... , , Firefox ( ).
, , , , :
Edit
, If-Unmodified-Since, Firefox . , Last-Modified , Apache, - 404. If-Unmodified-Since .htaccess:
<Files test-xs.php>
RequestHeader unset If-Unmodified-Since
</Files>
... , Firefox.
, , , , , .
, , , , , , , .
: