Kasun
Kasun

Reputation: 682

Setting Spring Boot property server.compression.enabled to true doesn't get applied to the autoconfigured Tomcat Server

I'm using Spring Boot 2.0.6.RELEASE and trying to get the internal Tomcat server to GZip the responses from the API I'm working on. As per the spring boot documentation https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/htmlsingle/#how-to-enable-http-response-compression adding server.compression.enabled=true to the application.properties should enable embedded web server's compression.

However the response I'm getting from the API doesn't look compressed.

API response

I've followed this question Spring boot response compression not working and when inspecting the ServerProperties's Compression object when application starts up, it looks like the enabled property is set to false.

enter image description here

What am I missing here?

Upvotes: 3

Views: 15029

Answers (2)

Chirag Bansal
Chirag Bansal

Reputation: 21

Compression is disabled if strong Etag is enabled. I was using ShallowEtagHeaderFilter and as soon as I removed it, compression started working.

Upvotes: 1

Pranay Kumbhalkar
Pranay Kumbhalkar

Reputation: 701

Specify mime-types with compression like below.

server.compression.enabled=true
server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain

Upvotes: 2

Related Questions