Document Tomcat compression and GzipFilter auto-configuration
Closes gh-2031
This commit is contained in:
parent
69ea4beb8a
commit
e2f2839d32
|
@ -74,6 +74,8 @@ content into your application; rather pick only the properties that you need.
|
|||
server.ssl.trust-store-type=
|
||||
server.tomcat.access-log-pattern= # log pattern of the access log
|
||||
server.tomcat.access-log-enabled=false # is access logging enabled
|
||||
server.tomcat.compression=off # is compression enabled (off, on, or an integer content length limit)
|
||||
server.tomcat.compressableMimeTypes=text/html,text/xml,text/plain # comma-separated list of mime types that Tomcat will compress
|
||||
server.tomcat.internal-proxies=10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\
|
||||
192\\.168\\.\\d{1,3}\\.\\d{1,3}|\\
|
||||
169\\.254\\.\\d{1,3}\\.\\d{1,3}|\\
|
||||
|
@ -105,6 +107,19 @@ content into your application; rather pick only the properties that you need.
|
|||
spring.http.encoding.enabled=true # enable http encoding support
|
||||
spring.http.encoding.force=true # force the configured encoding
|
||||
|
||||
# HTTP response compression ({sc-spring-boot-autoconfigure/web/GzipFilterProperties.{sc-ext}[GzipFilterProperties])
|
||||
spring.http.gzip.bufferSize= # size of the output buffer in bytes
|
||||
spring.http.gzip.minGzipSize= # minimum content length required for compression to occur
|
||||
spring.http.gzip.deflateCompressionLevel= # the level used for deflate compression (0-9)
|
||||
spring.http.gzip.deflateNoWrap= # noWrap setting for deflate compression (true or false)
|
||||
spring.http.gzip.methods= # comma-separated list of HTTP methods for which compression is enabled
|
||||
spring.http.gzip.mimeTypes= # comma-separated list of MIME types which should be compressed
|
||||
spring.http.gzip.excludedAgents= # comma-separated list of user agents to exclude from compression
|
||||
spring.http.gzip.excludedAgentPatterns= # comma-separated list of regular expression patterns to control user agents excluded from compression
|
||||
spring.http.gzip.excludedPaths= # comma-separated list of paths to exclude from compression
|
||||
spring.http.gzip.excludedPathPatterns= # comma-separated list of regular expression patterns to control the paths that are excluded from compression
|
||||
spring.http.gzip.vary= # Vary header to be sent on responses that may be compressed
|
||||
|
||||
# JACKSON ({sc-spring-boot-autoconfigure}}/jackson/JacksonProperties.{sc-ext}[JacksonProperties])
|
||||
spring.jackson.date-format= # Date format string (e.g. yyyy-MM-dd HH:mm:ss), or a fully-qualified date format class name (e.g. com.fasterxml.jackson.databind.util.ISO8601DateFormat)
|
||||
spring.jackson.property-naming-strategy= # One of the constants on Jackson's PropertyNamingStrategy (e.g. CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES) or the fully-qualified class name of a PropertyNamingStrategy subclass
|
||||
|
|
|
@ -740,6 +740,58 @@ not required.
|
|||
|
||||
|
||||
|
||||
[[how-to-enable-http-response-compression]]
|
||||
=== Enable HTTP response compression
|
||||
Spring Boot provides two mechanisms for enabling compression of HTTP compression; one
|
||||
that is Tomcat-specific and another that uses a filter and works with Jetty, Tomcat,
|
||||
and Undertow.
|
||||
|
||||
|
||||
|
||||
[[how-to-enable-http-response-compression-tomcat]]
|
||||
==== Enable Tomcat's HTTP response compression
|
||||
Tomcat provides built-in support for HTTP response compression. It is disabled by
|
||||
default, but can easily be enabled via `application.properties`:
|
||||
|
||||
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
server.tomcat.compression: on
|
||||
----
|
||||
|
||||
When set to `on` Tomcat will compress responses with a length that is at least 2048
|
||||
bytes. This limit can be configured by specifying an integer value rather than `on`,
|
||||
e.g.:
|
||||
|
||||
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
server.tomcat.compression: 4096
|
||||
----
|
||||
|
||||
By default Tomcat will only compress responses with certain MIME types
|
||||
(`text/html`, `text/xml`, and `text/plain`). You can customize this using the
|
||||
`server.tomcat.compressableMimeTypes` property, e.g.:
|
||||
|
||||
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
server.tomcat.compressableMimeTypes=application/json,application/xml
|
||||
----
|
||||
|
||||
|
||||
|
||||
[[how-to-enable-http-compression-gzip-filter]]
|
||||
==== Enable HTTP response compression using GzipFilter
|
||||
If you're using Jetty or Undertow, or you want more sophisticated control over
|
||||
HTTP response compression, Spring Boot provides auto-configuration for Jetty's
|
||||
`GzipFilter`. While this filter is part of Jetty, it's compatible with Tomcat
|
||||
and Undertow as well. To enable the filter, simply add a dependency on
|
||||
`org.eclipse.jetty:jetty-servlets` to your application.
|
||||
|
||||
`GzipFilter` can be configured using the `spring.http.gzip.*` properties. See
|
||||
{sc-spring-boot-autoconfigure}/web/GzipFilterProperties.{sc-ext}[`GzipFilterProperties`]
|
||||
for more details.
|
||||
|
||||
|
||||
|
||||
[[howto-spring-mvc]]
|
||||
== Spring MVC
|
||||
|
||||
|
|
Loading…
Reference in New Issue