HTTP compression is a capability that can be built into web servers and web clients to improve transfer speed and save bandwidth utilisation. The commonly used compression is GZIP.
By default, the
gzip compression is disabled in Spring Boot application. However, we can enable compression using the few property changes.
Add the following configuration to spring boot application.properties file.
The above configuration will enable the gzip compression for all responses for the given mime-types defined in the property file.
The wildcard in mime-types are not supported. So we need to explicitly provide all the list of mime-types.
Please note, gzip operation consumes time and a lot of server resources. For this, you may enable the compression-only when the response exceeds a limit.
# Minimum response where compression will kick in server.compression.min-response-size=4096
If you are using YAML configuration file, these properties will look like this: