Whenever we are delivering content to a client, it must be make sure that the page of the website should be loaded as fast as possible. Compression is a good option, gzip is one of the options available out there. So, for this post only we are going to understand about nginx with gzip compression.
Note: In order to get this functionality in your nginx server, make sure that the version of nginx you are using is being compiled with the gzip module.
Question: How to confirm that your nginx installation is already have gzip module with it?
Answer: Simply run the command as shown in the picture below.
From the output of the command used above, you can confirm the module’s presence. You will be seeing one of the following or both:
Note: Now that we have confirmed that, gzip module is installed with our nginx installation. It is time to check whether it is enabled on the server or not.
Question: How to check whether gzip is enabled in nginx server?
Answer: You have to confirm the same by looking into your server’s maine configuration file, which is most of the times placed at “/etc/ngin/nginx.conf“.
Check whether gzip is enabled in Nginx or not
Step 1: By looking into the main configuration file of nginx.
From the above we can see that “gzip on” setting is enabled in the configuration file.
Step 2: Check whether it is working on browser site or not.
In order to do that you have to enter into “inspect section” of your browser, to achieve that use the combination of “Ctrl+Shift+I” from your keyboard or “Right Click Options” from your mouse.
Step 3: Look for “Content-Type” under the “Response Headers” section of a particular link or any element.
Notice from the photo above it is showing:
Note one more thing, it is also showing:
Note: Go to “content type” to learn more.
Everything discussed and learned above confirmed that “gzip compression is enabled in nginx server”, after that we have also seen the practical way to confirm the same.