Let's say I have a very simple HTTP endpoint using Spring Webflux:
@GetMapping
fun greeting(@RequestParam("msg") val message : String) = Mono.just(Greeting(message))
where Greeting is a simple DTO serialized as JSON. How can I instruct Spring Webflux to return the response compressed as GZIP? I'm using the Netty implementation if that matters.
What you are looking for is server compression properties
server.compression.enabled=true
server.compression.min-response-size=1024
Adding to above-accepted answer, it's always better to give min-response-size as well to remove server overhead of compressing all responses and also the the mime-types.
server.compression.enabled=true
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json,application/xml
server.compression.min-response-size=2KB
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With