簡體   English   中英

壓縮/ gzip壓縮不起作用

[英]deflate/gzip compression not working

我有經典的共享托管(Apache)。 在phpinfo()中都啟用了它。

啟用gzip壓縮

我試圖用這個:

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

還有這個:

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE application/x-javascript application/javascript text/javascript text/css text/html text/xml
</IfModule>

但這對我不起作用。 響應頭是:

HTTP/1.1 200 OK
Date: Mon, 03 Aug 2015 15:29:08 GMT
Server: Apache
Last-Modified: Mon, 03 Aug 2015 14:28:34 GMT
ETag: "64325f33-1ebd5-51c68fc093cbc"
Accept-Ranges: bytes
Cache-Control: max-age=604800
Expires: Mon, 10 Aug 2015 15:29:08 GMT
Vary: Accept-Encoding
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: application/javascript
Transfer-Encoding: chunked

因此缺少Content-Encoding gzip 如果我使用腳本運行腳本,它將向我顯示

已啟用GZIP。使用GZIP壓縮此頁面可節省72.9%。

但是在我的代碼中,它不起作用(沒有壓縮)。 我應該怎么做/嘗試?

我認為壓縮工作正常。 服務器未按預期方式響應,因為根據RFC ,您需要通過向請求中添加帶有支持的內容編碼之一的Accept-Encoding標頭來指定要壓縮的響應。

Accept-Encoding: gzip, deflate

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM