SpringBoot gzip compression not working anymore

Viewed 965

After upgrading from SpringBoot 2.1.9 to 2.2.5 gzip compression is not working anymore. Is it possible that the configuration parameters have changed?

I'm using SpringBoot with OpenJDK 11.

Configuration parameters:

server.compression.enabled=true
# The comma-separated list of mime types that should be compressed
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json
# Compress the response only if the response size is at least 1KB
server.compression.min-response-size=1024

I verified the response headers in the latest chrome version.

1 Answers

The problem occurs when switching the spring version from 2.1.11 to 2.1.12. The embedded tomcat version changes from 9.0.29 to 9.0.30.

From tomcat 9.0.30 on, the compression will not be used for assets with a strong etag, so your assets are served uncompressed.

I was able to fix this issue by making the etag weak:

val shallowEtagHeaderFilter = ShallowEtagHeaderFilter()
shallowEtagHeaderFilter.isWriteWeakETag = true

Reference:

Related