Spring Boot + GZIP - Hello World Example
What is GZIP? Need for it?When a user hits the website a call is made to the server to return the requested files. If these requested files are large, it takes a longer time to reach the browser and get displayed.
Gzip compresses the webpages and style sheets before sending them over to the browser. This reduces the page loading time, less bandwidth usage and better user experience.
Consider a scenario when you visit this web site - www.javainuse.com . Then following operations are performed.
VideoThis tutorial is explained in the below Youtube Video.
Lets Begin-In this tutorial we will implement GZIP at the tomcat level. We will see how to implement this for
- Deploying Spring Boot Application for Embedded Tomcat.
- Deploying Spring Boot Application as war to external Tomcat.
Deploying Spring Boot Application for Embedded TomcatIn previous example we had implemented a Spring Boot File download Example
We will be using the same example to implement GZIP.
The Maven project will be as follows-
Start the Application, and go to localhost:8080/download/file/boot.jpg We can see the image inline as follows -