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

1

7

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

Mccloskey answered 22/10, 2018 at 7:37 Comment(1)
fyi, according to the documentation you could also write 10KB instead of 10240Pros
K
1

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.

Kneehigh answered 17/2, 2020 at 14:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.