From 687ed9f9d6a29af52e765cb7a7f91566b59e29d2 Mon Sep 17 00:00:00 2001 From: qibaoguang Date: Sun, 29 Mar 2015 00:54:53 +0800 Subject: [PATCH] =?UTF-8?q?Update=2064.17.1.=20Enable=20Tomcat=E2=80=99s?= =?UTF-8?q?=20HTTP=20response=20compression.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...17.1. Enable Tomcat’s HTTP response compression.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/IX. ‘How-to’ guides/64.17.1. Enable Tomcat’s HTTP response compression.md b/IX. ‘How-to’ guides/64.17.1. Enable Tomcat’s HTTP response compression.md index 626c917..5ae73d6 100644 --- a/IX. ‘How-to’ guides/64.17.1. Enable Tomcat’s HTTP response compression.md +++ b/IX. ‘How-to’ guides/64.17.1. Enable Tomcat’s HTTP response compression.md @@ -1,3 +1,14 @@ -### 64.17.1. 启用HTTP响应压缩 +### 64.17.1. 启用Tomcat的HTTP响应压缩 -Spring Boot提供两种启用HTTP压缩的机制;一种是Tomcat特有的,另一种是使用一个filter,可以配合Jetty,Tomcat和Undertow。 +Tomcat对HTTP响应压缩提供内建支持。默认是禁用的,但可以通过application.properties轻松的启用: +```java +server.tomcat.compression: on +``` +当设置为`on`时,Tomcat将压缩响应的长度至少为2048字节。你可以配置一个整型值来设置该限制而不只是`on`,比如: +```java +server.tomcat.compression: 4096 +``` +默认情况下,Tomcat只压缩某些MIME类型的响应(text/html,text/xml和text/plain)。你可以使用`server.tomcat.compressableMimeTypes`属性进行自定义,比如: +```java +server.tomcat.compressableMimeTypes=application/json,application/xml +```