Spring Boot: Response Compression
Spring boot provides a facility to compress your resources by changing minimum configuration. Below is the available properties related to compression, it should be added into your configuration file (usually
This is a flag to enable response compression.
Possible values = true or false
You can give list of user-agents which needs to be exclude from compression.
Example Values: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0
You can give Comma-separated list of MIME types that should be compressed.
Using this property you can restrict compression based on response size in bytes. Value is minimum response size that is required for compression to be performed.
Example value: 2048
After enabling compression you can check your response size by inspecting using firebug (that what i have used) or some other inspection tool. And also you can find “Content-Encoding=gzip” in your response headers.
That’s it for boot compression methods.
I want to discuss one more thing related to compression here, while looking best methods or tools for response compression i came to visit one portal which is provided by google.
The most useful thing found here is code refactoring,
- it minimize a variable name
- convert inline if condition
- convert if…else clause to ternary operator
and many more changes which will help us to reduce our script content.
Share current post by copy: https://goo.gl/jPtRrv
Hope it may help you somewhere.
Happy learning :).