4

I created configuration to compress responses with spring boot. Below is my configuration.

@Bean
public ServerProperties serverProperties() {
    final ServerProperties serverProperties = new ServerProperties();
    serverProperties.getCompression().setMimeTypes(new String[] {"text/html","text/xml","text/plain","text/css","application/json"});
    serverProperties.getCompression().setEnabled(true);
    return serverProperties;
}

The problem is that all responses have header [Content-Encoding →gzip], even this with smaller response size than min response size, which is 2048 bytes by default.

Dawid Macura
  • 193
  • 1
  • 9

1 Answers1

6

Could be related to this (in my case it is):
https://jira.spring.io/browse/SPR-15212

Spring(mvc) http response typically is 'transfer-encoding: chunked', and hence does not have content-length.
Without content-length the compression.min-response-size cannot be honored.

For typical server, technique to provide content-length is here.

cheenu
  • 138
  • 2
  • 8