How to Check If Web Server Supports Gzip

Objective: Check if web server supports the serving of gzipped content.

We can use curl to test if a apache or nginx web server is configured to server gzipped content. The "Accept-Encoding: gzip,deflate" request header is used to inform the server that the client accepts gzip encoding. If the server supports gzip encoding and if response header from the web server indicates “Content-Encoding: gzip”, then the content is gzipped.

$ curl -svo /dev/null -H "Accept-Encoding: gzip,deflate"  
* Rebuilt URL to:
* Hostname was NOT found in DNS cache
*   Trying
* Connected to ( port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host:
> Accept: */*
> Accept-Encoding: gzip,deflate
< HTTP/1.1 200 OK
< Date: Tue, 03 May 2016 09:08:32 GMT
< Content-Type: text/html
< Content-Length: 13271
< Connection: keep-alive
< Set-Cookie: __cfduid=d6715588427f12aa8979fc30f9576ee661462266512; expires=Wed, 03-May-17 09:08:32 GMT; path=/;; HttpOnly
< Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT
< Expires: Tue, 03 May 2016 10:00:57 GMT
< Pragma: public
< Cache-Control: max-age=3600, public
< Etag: 6d7e9854d8152b5474c213c405236884
< Content-Encoding: gzip
< Vary: Accept-Encoding
< Accept-Ranges: bytes
< X-Varnish: 1836835174 1836835064
< Age: 455
< X-Cache: HIT
* Server cloudflare-nginx is not blacklisted
< Server: cloudflare-nginx
< CF-RAY: 29d291a7f01d11e9-SJC
{ [data not shown]
* Connection #0 to host left intact

If you are only interested in the "Accept-Encoding" and "Content-Encoding" headers, you can use the following syntax to filter the output.

$ curl -svo /dev/null -H "Accept-Encoding: gzip,deflate" 2>&1 | grep -i "encoding"
> Accept-Encoding: gzip,deflate
< Content-Encoding: gzip

If your server is configured for gzipped content, but if it's not working as expected, check for the presence of the "Via" request header. This header is usually inserted by proxies. The "Via" header can disable gzip compression unless the web server is configured to compress proxied requests. On Nginx, this is controlled by the "gzip_proxied" parameter.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }