deflate/gzip 压缩无效
deflate/gzip compression not working
我有经典的共享主机 (apache)。在 phpinfo() 中,它都已启用。
gzip compression enabled
我试过用这个:
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>
但这对我不起作用。响应 headers 是:
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
。如果我 运行 我的脚本使用 this 它会显示
It's GZIP Enabled.72.9%
Was saved by compressing this page with GZIP.
但在我的代码中它不起作用(没有压缩)。我应该do/try做什么?
我认为压缩工作正常。服务器未按预期响应,因为 according RFC, you need to specify that you want to have compressed response by adding Accept-Encoding header with one of supported content-codings 您的请求。
Accept-Encoding: gzip, deflate
我有经典的共享主机 (apache)。在 phpinfo() 中,它都已启用。
gzip compression enabled
我试过用这个:
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>
但这对我不起作用。响应 headers 是:
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
。如果我 运行 我的脚本使用 this 它会显示
It's GZIP Enabled.72.9% Was saved by compressing this page with GZIP.
但在我的代码中它不起作用(没有压缩)。我应该do/try做什么?
我认为压缩工作正常。服务器未按预期响应,因为 according RFC, you need to specify that you want to have compressed response by adding Accept-Encoding header with one of supported content-codings 您的请求。
Accept-Encoding: gzip, deflate