tomcat6上的Gzip压缩
两者的区别是什么 compression=“on” 及 compression=“force” ? 说: “开”-允许压缩,这会导致文本数据被压缩 “力”-所有情况下的压缩力 额外的箱子是什么tomcat6上的Gzip压缩,tomcat,compression,gzip,tomcat6,Tomcat,Compression,Gzip,Tomcat6,两者的区别是什么 compression=“on” 及 compression=“force” ? 说: “开”-允许压缩,这会导致文本数据被压缩 “力”-所有情况下的压缩力 额外的箱子是什么 而且,更重要的是,建议在生产环境中使用哪个值?压缩还是不压缩,取决于过程 强制压缩意味着服务器将发送压缩的内容,无论客户端是否支持它。我不能100%确定区别是什么(我在寻找相同的信息),但我可以肯定地说,当客户端没有发送相关的接受编码头时,“force”值不会压缩,根据我刚刚执行的测试(使用tomcat
而且,更重要的是,建议在生产环境中使用哪个值?压缩还是不压缩,取决于过程
强制压缩意味着服务器将发送压缩的内容,无论客户端是否支持它。我不能100%确定区别是什么(我在寻找相同的信息),但我可以肯定地说,当客户端没有发送相关的接受编码头时,“force”值不会压缩,根据我刚刚执行的测试(使用tomcat 8.0.8)。此外,它也没有什么意义,会破坏这么多http客户机 我想“开”和“力”的区别在于其他压缩参数。例如,“on”将使用compressablemmetype和nocompressionseragents,而“force”将忽略这两个参数进行压缩(例如,对于所有mime类型和所有用户代理)。实际上,如果客户机支持压缩,“force”只是force 请注意,在“内容编码”标题检查之后,强制为
/**
* Check if the resource could be compressed, if the client supports it.
*/
private boolean isCompressible() {
// Check if content is not already compressed
MessageBytes contentEncodingMB = response.getMimeHeaders().getValue("Content-Encoding");
if ((contentEncodingMB != null) &&
(contentEncodingMB.indexOf("gzip") != -1 ||
contentEncodingMB.indexOf("br") != -1)) {
return false;
}
// If force mode, always compress (test purposes only)
if (compressionLevel == 2) {
return true;
}
...
我认为这是由于签入使用压缩
/**
* Check if compression should be used for this resource. Already checked
* that the resource could be compressed if the client supports it.
*/
private boolean useCompression() {
// Check if browser support gzip encoding
MessageBytes acceptEncodingMB =
request.getMimeHeaders().getValue("accept-encoding");
if ((acceptEncodingMB == null)
|| (acceptEncodingMB.indexOf("gzip") == -1)) {
return false;
}
// If force mode, always compress (test purposes only)
if (compressionLevel == 2) {
return true;
}