Nginx server – How to configure Gzip Compression

Saul Goodman May 16, 2019 Loading...

This article teaches you how to configure Gzip Compression on your Nginx server, so that your websites will load much faster.

1. Open the configuration file for your Nginx server:

sudo nano /etc/nginx/nginx.conf

2. In the file, locate the line “gzip on; ” and add the following code after it:

gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript application/ application/x-font-ttf font/opentype
image/svg+xml image/x-icon;

3. Restart Nginx:

sudo systemctl restart nginx

4. Test: use Chrome web developer tool or an online tool like to make sure your settings OK.


  • Tag
  • Related posts

    Welcome to KINDACODE. Have a nice day and code well!