Replace GzipFilter and Tomcat compression with general purpose approach
Closes gh-3296
This commit is contained in:
@@ -66,6 +66,9 @@ content into your application; rather pick only the properties that you need.
|
||||
server.port=8080
|
||||
server.address= # bind to a specific NIC
|
||||
server.session-timeout= # session timeout in seconds
|
||||
server.compression.enabled=false # if response compression is enabled
|
||||
server.compression.mime-types=text/html,text/xml,text/plain,text/css # comma-separated list of MIME types that should be compressed
|
||||
server.compression.min-response-size=2048 # minimum response size that is required for compression to be performed
|
||||
server.context-parameters.*= # Servlet context init parameters, e.g. server.context-parameters.a=alpha
|
||||
server.context-path= # the context path, defaults to '/'
|
||||
server.jsp-servlet.class-name=org.apache.jasper.servlet.JspServlet # The class name of the JSP servlet
|
||||
@@ -89,8 +92,6 @@ 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.compressable-mime-types=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}|\\
|
||||
@@ -156,21 +157,6 @@ content into your application; rather pick only the properties that you need.
|
||||
# HTTP message conversion
|
||||
spring.http.converters.preferred-json-mapper= # the preferred JSON mapper to use for HTTP message conversion. Set to "gson" to force the use of Gson when both it and Jackson are on the classpath.
|
||||
|
||||
# HTTP response compression ({sc-spring-boot-autoconfigure}/web/GzipFilterProperties.{sc-ext}[GzipFilterProperties])
|
||||
spring.http.gzip.buffer-size= # size of the output buffer in bytes
|
||||
spring.http.gzip.deflate-compression-level= # the level used for deflate compression (0-9)
|
||||
spring.http.gzip.deflate-no-wrap= # noWrap setting for deflate compression (true or false)
|
||||
spring.http.gzip.enabled=true # enable gzip filter support
|
||||
spring.http.gzip.excluded-agents= # comma-separated list of user agents to exclude from compression
|
||||
spring.http.gzip.exclude-agent-patterns= # comma-separated list of regular expression patterns to control user agents excluded from compression
|
||||
spring.http.gzip.exclude-paths= # comma-separated list of paths to exclude from compression
|
||||
spring.http.gzip.exclude-path-patterns= # comma-separated list of regular expression patterns to control the paths that are excluded from compression
|
||||
spring.http.gzip.methods= # comma-separated list of HTTP methods for which compression is enabled
|
||||
spring.http.gzip.mime-types= # comma-separated list of MIME types which should be compressed
|
||||
spring.http.gzip.excluded-mime-types= # comma-separated list of MIME types to exclude from compression
|
||||
spring.http.gzip.min-gzip-size= # minimum content length required for compression to occur
|
||||
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
|
||||
|
||||
@@ -834,53 +834,27 @@ 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`:
|
||||
HTTP response compression is supported by Jetty, Tomcat, and Undertow. It can be enabled
|
||||
via `application.properties`:
|
||||
|
||||
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
server.tomcat.compression=on
|
||||
server.compression.enabled=true
|
||||
----
|
||||
|
||||
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.:
|
||||
By default, responses must be at least 2048 bytes in length for compression to be
|
||||
performed. This can be configured using the `server.compression.min-response-size`
|
||||
property.
|
||||
|
||||
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
server.tomcat.compression=4096
|
||||
----
|
||||
By default, responses will only be compressed if their content type is one of the
|
||||
following:
|
||||
|
||||
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.:
|
||||
- `text/html`
|
||||
- `text/xml`
|
||||
- `text/plain`
|
||||
- `text/css`
|
||||
|
||||
[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.
|
||||
This can be configured using the `server.compression.mime-types` property.
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user