를 통해 다운로드 gzip으로 압축 :파일은 이후에 내가 PHP 스크립트를 통해 (파일을 열 수있다)는 서버에있는 PDF 파일을 다운로드하고 PHP
ini_set("zlib.output_compression", "Off"); // just to be sure
$quoted = sprintf('"%s"', addcslashes(basename($fileName), '"\\'));
$size = filesize($fileName); // size at this stage is correct
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $quoted);
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . $size);
ob_clean();
flush();
readfile($fileName);
ini_set("zlib.output_compression", "On");
exit;
다운로드 된 파일은 gzip으로 압축된다. 원본보다 크기가 작습니다. .gz 확장자가 끝에 추가되고 파일이 추출 될 때까지 열 수 없습니다.
서버 API의 CGI/FastCGI를
PHP 버전 7.1.0
이 Lighttpd 1.4.35
요청 헤더
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:en-US,en;q=0.8
Authorization:Basic ************
Cache-Control:max-age=0
Connection:keep-alive
Host:dev.*********.lv
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
응답 헤더
Cache-Control:must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Description:File Transfer
Content-Disposition:attachment; filename="INV_AUC15-3_U1_DDDDD-IIII_03112016.pdf"
Content-Length:831807
Content-Transfer-Encoding:binary
Content-Type:application/octet-stream
Date:Wed, 04 Jan 2017 10:22:19 GMT
Expires:0
Last-Modified:Wed, 04 Jan 2017 10:22:19 GMT
Pragma:public
Server:FS
X-Powered-By:PHP/7.1.0
Content-Length 헤더가 정확합니다 (파일 시스템에서와 동일).
PDF 파일을 가리키는 전체 URL을 입력하면 파일이 아무런 문제없이 다운로드되어 열립니다.
대상 파일을 다운로드 한 후/그 전에 왜 조용히 gzip으로 처리합니까? 그 일을하지 않았다 몇 가지 이유
ini_set("zlib.output_compression", "Off");
및 변수에 대한 크롬, 파이어 폭스, 사파리에서 테스트
, 오페라