Response compression is controlled in the http, server, location, or if in location context. gzip on enables gzipping of responses, off by default; gzip_comp_level sets a compression level from 1 to 9 with a default of 1; gzip_min_length, default 20, sets the minimum response length to compress, determined only from the Content-Length response header. gzip_types names additional MIME types to compress beyond text/html — responses of that type are always compressed — and the special value * matches any MIME type since 0.8.29; restricting gzip_types to textual types, since compressing already-compressed formats gains little, is Koskamo editorial guidance. gzip_proxied, off by default, decides whether responses to proxied requests are compressed depending on the request and response. gzip_disable, available since 0.6.23, skips gzipping for requests whose User-Agent matches given regular expressions, with the special mask msie6 since 0.7.12. gzip_vary on inserts the Vary: Accept-Encoding response header when compression is active, and the $gzip_ratio variable reports the achieved compression ratio. Scope: nginx. Reviewed October 4, 2026.
gzip compression of responses
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- nginx.org
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.