Gzip Compression
1 min read
- Authors
- Name
- Vijaykumar Rajendran
- @vijayrajendran_

Table of Contents
Gzip Compression
Enable Gzip
http {
gzip on;
gzip_comp_level 6;
gzip_min_length 256;
gzip_types text/plain text/css application/json application/javascript;
gzip_vary on;
}
Settings Explained
gzip_comp_level 6- Compression level 1-9 (1=fast, 9=best)gzip_min_length 256- Don't compress files smaller than 256 bytesgzip_types- Which content types to compressgzip_vary- Add Vary header for caches
Compression Reduction
With gzip:
- HTML: 60-70% smaller
- CSS: 70-80% smaller
- JavaScript: 60-70% smaller
- JSON: 50-60% smaller
Disable for Images
gzip off;
gzip_types text/plain text/css application/json application/javascript;
# Images already compressed
location ~* \.(jpg|png|gif|woff|woff2)$ {
gzip off;
}
Speed matters!