这很奇怪,我用谷歌搜索了一个问题,但毫无进展。我有 2 台服务器(centos6、apache2.2)。apache 配置完全相同(我确定,apache 由 puppet 配置)
我的deflate.conf:
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript text/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/json
当我curl -I --压缩http://web1.tld/file.css我收到以下回复:
HTTP/1.1 200 OK
Date: Fri, 19 Sep 2014 15:02:21 GMT
Server: Apache
Last-Modified: Fri, 19 Sep 2014 08:36:46 GMT
ETag: "189dc-50367005ed32a"
Accept-Ranges: bytes
Cache-Control: max-age=2419200
Expires: Fri, 17 Oct 2014 15:02:21 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 16191
Content-Type: text/css
没关系,我明白内容编码:gzip
与第二台服务器:curl -I --压缩http://web2.tld/file.css
HTTP/1.1 200 OK
Date: Fri, 19 Sep 2014 15:03:47 GMT
Server: Apache
Last-Modified: Fri, 19 Sep 2014 08:36:46 GMT
ETag: "189dc-50367005ed32a"
Accept-Ranges: bytes
Content-Length: 100828
Cache-Control: max-age=2419200
Expires: Fri, 17 Oct 2014 15:03:47 GMT
Vary: Accept-Encoding
Content-Type: text/css
但这是不行的:内容长度:100828和不标题内容编码:gzip
但是!奇怪的是:当我从 web1 向 web2 服务器发出相同请求时 - web2 上启用了 gzip!
另外请告知是否可以仅当请求具有“Accept-Encoding”时才发送“Vary”标头?