I would like to enable GZIP compression for my web application. I searched over the Internet and found 2 different options:
GzipResourceResolver
resolver like described here: http://kielczewski.eu/2014/11/static-resources-in-spring41/
Both options is okay for me but I want to understand the difference and which approach is better. Please assist.
In addition, what will happen if I enable both options? Will servlet container try to compress already compressed files?
p.s. In my opinion 2nd options will be faster as there no need to compress response each time - compressed files will be prepared during build phase.
Crucially, GZIP is much faster server-side compared to Brotli — lower end devices and/or servers will run better with the older compression technique.
Gzip is a fast and easy way to improve page speed performance while still delivering a high-quality experience to your users. See if your website supports gzip by running a free speed test, and sign up for a free trial for more insights into your website's performance.
Why Do We Use GZIP Compression? GZIP is effective, but it's not the only compression method out there. In fact, it's not even the best method in terms of size reduction. GZIP can reduce the amount of data by up to 70%.
If both compressions are enabled , compression would be done at both the layers. As per spring docs, there is an overhead at server in enabling spring gzip compression . If you have application deployed in container like tomcat, compression can be enabled there as well. But enabling compression at container like tomcat is better as it will be applicable for all the resources(Js, images etc) as compared to enabling gzip compression at spring which might be serving a part of resources. Also double compressing a gzip file would add to overhead and there wont be any significant compression achieved.
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