I have a spring project where I need to compress the JSON response if the size of the response is greater that 2KB.
Spring has the property server.compression.min-response-size=2048 but is only does it for response of type String.
Recommendation from spring team as below
- The minimum size is only honored if the size is known before the body is written, thanks to the "Content-Length" response header. If you really want to honor this is all cases, you would need to buffer the entire JSON response body and then write it at once; this is likely to make performance worse.*
What is the best way to achieve this if performance impact is not taken into consideration?