Setting the Spring Boot property server.compression.enabled to true does not apply to automatically configured Tomcat servers
I’m using Spring Boot 2.0.6.RELEASE and trying to have the internal Tomcat server GZip compress the response to the API that I am processing. According to the Spring Boot documentation, https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle/#how-to-enable-http-response-compression set server.compression.enabled= True
added to application.properties should enable compression for the embedded Web server.
However, the response I get from the API doesn’t look compressed.
I’ve followed this issue Spring boot response compression is not working, and when the Compression object of ServerProperties is checked at application startup, the enabled property appears to be set to false.
What am I missing here?
Solution
Specify mime-types
to compress as follows.
server.compression.enabled=true
server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain