nginx/tengin 沒有開啟php檔案的gzip,但為什麼回傳頭卻有Content-Encoding: gzip
过去多啦不再A梦
过去多啦不再A梦 2017-05-16 17:22:04
0
1
769

nginx gzip 設定如下:

gzip on;
gzip_min_length  1k;
gzip_buffers     4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types       text/plain application/x-javascript application/javascript text/css application/xml;
gzip_vary on;

用 curl 或 chrome 測試

$curl -I -H "Accept-Encoding: gzip, deflate" "http://localhost/template/tpl_header.php"

HTTP/1.1 200 OK
Server: Tengine/2.1.0
Date: Sat, 05 Sep 2015 16:40:34 GMT
Content-Type: text/html
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.5.27
Content-Encoding: gzip

請求 jpg 圖片則正常

curl -I -H "Accept-Encoding: gzip, deflate" "http://localhost/asset/image/common/bg.jpg"

HTTP/1.1 200 OK
Server: Tengine/2.1.0
Date: Sat, 05 Sep 2015 16:43:36 GMT
Content-Type: image/jpeg
Content-Length: 4817
Last-Modified: Sat, 15 Aug 2015 13:12:10 GMT
Connection: keep-alive
ETag: "55cf3aaa-12d1"
Expires: Mon, 05 Oct 2015 16:43:36 GMT
Cache-Control: max-age=2592000
Accept-Ranges: bytes

請問這是什麼原因?

附上編譯參數:

./configure --prefix=/usr/local/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --conf-path=/etc/nginx/nginx.conf --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --pid-path=/var/run/nginx.pid --with-cc-opt="-Wno-deprecated-declarations"
过去多啦不再A梦
过去多啦不再A梦

全部回覆(1)
Ty80

因為你的php的header輸出為text/html

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板