Springboot gzip compressing responses having size less than min-response-size configured

Viewed 2773

I am trying to implement Gzip response compression in my Springboot Rest API

I am using below configuration in my application.properties

# Enable response compression
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 10KB
server.compression.min-response-size=10240

Response compression is happening, but the strange thing is that it is also compression responses having size as low as 1KB or 500B which it should not as server.compression.min-response-size=10240

1 Answers

Are you sure that you are looking at the uncompressed size of the file received, rather than the compressed size actually sent across (as shown in a browsers network tab)?

The web server will check the file size on disc is over the 'server.compression.min-response-size' and compress it if so - this could result in a compressed file being below the value set?

Once the CPU has done the work to compress the file, there is little point then sending the uncompressed version.

Related