
Compressing responses typically considerably reduces the dimensions of transmitted data. However, since compression happens at runtime it may possibly also add considerable processing overhead which might negatively affect performance. NGINX performs compression earlier than sending responses to purchasers, but doesn’t “double compress” responses that are already compressed (for example, by a proxied server). Altering Nginx configuration to utilize gzip compression is easy, but the advantages can be immense.
Previous Article
The general configuration of gzip compression would possibly appear to be this. Now, the Gzip compression ratio ought to be appended as the last subject in every log entry in the specified access log file. The worth indicates the compression ratio achieved for that particular request/response. For those of you who don’t know, gzip compression permits your web site to load quicker. Run the following command to verify syntax of your updated config file.
Restart Nginx Server
- In flip, your users have to obtain less information every time they request a page.
- By following the steps to examine activation and configure settings, you can enhance your server’s performance.
- No, you can not use each Gzip and Deflate compression simultaneously in Nginx.
- Observe that this directive is outlined in a separate module that might not be included in an NGINX Open Supply build by default.
Add/Uncomment the next lines in your NGINX configuration file, or add them to http or server block, as per your requirement. In this step, we’ll create a quantity of check recordsdata in the default Nginx directory. We’ll use these information later to verify Nginx’s default behavior for gzip’s compression and check that the configuration changes have the intended impact. In this tutorial, you will configure Nginx to use gzip compression. This will scale back the size of content material sent to your website’s visitors and enhance performance.
To send a compressed model of a file to the client as a substitute of the regular one, set the gzip_static directive to on inside the acceptable context. The default location of the configuration file is /etc/nginx/nginx.conf. Alternatively, you’ll find it within the /etc/nginx/conf.d/ directory. To view the Gzip compression ratio in Nginx logs, you possibly can alexhost.com allow the $gzip_ratio variable in the log format configuration. To enable Gzip compression in Nginx, you will need root access to your server. On your server you need to edit the /etc/nginx/nginx.conf file and add the next.
