如果我为我的apache服务器启用了H2,并在HTML Dokument上指定了一个预加载的链接头,服务器执行H2服务器推送,因为它parsing了链接头 – 到目前为止这么好。
问题是这个推送的资源是在没有压缩的情况下交付的。
我猜这是因为服务器推送剂量不会创buildHTTP请求,因此不提供accept-encoding
请求标头。 事情是,如果客户端必须下载未压缩的内容,我不会得到任何性能改进。 仍然可以提供压缩的内容吗? 也许是基于HTML文档中的accept-encoding
请求头?
我的Apacheconfiguration :
<VirtualHost *:443> Protocols h2 http/1.1 [...] <Location /index.html> Header add Link "</css/all.min.css>;rel=preload;as=style" </Location> [...] </VirtualHost>
HTML标题 :
从HTML文档请求标题
accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 accept-encoding:gzip, deflate, sdch, br accept-language:de,en-US;q=0.8,en;q=0.6 cache-control:no-cache
来自HTML文档的响应标题
accept-ranges:bytes cache-control:no-transform,public,max-age=300,s-maxage=900 content-encoding:gzip content-length:2183 content-type:text/html etag:"2472-5385af4b7bbda-gzip" last-modified:Sun, 24 Jul 2016 05:29:47 GMT link:</css/all.min.css>;rel=preload;as=style server:Apache/2.4.18 (Debian) status:200 vary:Accept-Encoding
来自/css/all.min.css的响应标题
accept-ranges:bytes cache-control:no-transform,public,max-age=300,s-maxage=900 content-length:14237 content-type:text/css etag:"379d-5385af4b9139b" last-modified:Sun, 24 Jul 2016 05:29:47 GMT server:Apache/2.4.18 (Debian) status:200 vary:Accept-Encoding
看起来这只是mod_http2
一个bug,但是它已经被修正为版本1.2.6: https : //github.com/icing/mod_h2/issues/86
我想你应该使用mod_deflate:
http://httpd.apache.org/docs/current/mod/mod_deflate.html#enable