javaspring-bootcompressionhttp-compressioncontent-encoding

POST responses not compressed despite Accept-Encoding Header being present in a request


I have encountered a strange case. I am working with a Spring Boot application which consists of a few different services.

For each service, in a application.properties file, those properties were added:

server.compression.enabled=true
server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,application/javascript,text/css
server.compression.min-response-size=1024

Now, it should work that every appropriate request contains "Accept-Encoding" header and response contains "Content-Encoding" header, and the response should be compressed.

It it almost works like that, but for one service POST responses do not contain "Content-Encoding", even though POST requests contain "Accept-Encoding". Such responses are not compressed, so it's not only about missing headers. GET responses/requests for this service work fine. Both GET/POST requests/responses for the rest of services work fine too.

This particular service's Spring Boot version is 1.5.16.RELEASE.

Where should I look for the cause? Can this setting be overwritten somehow for POST responses only?

Update: I also noticed that in POST responses for this service, "Vary: Accept-Encoding" header is missing. It's present in all other cases.


Solution

  • Try to change wiremock dependency configuration from compile to testCompile. In my case, wiremock in 2.22.0 version (with compile) caused this issue.