Linux / Unix Curl: Find Out If a Website Is Using Gzip / Deflate

by on November 9, 2012 · 1 comment· LAST UPDATED November 9, 2012

in , ,

How do I find out if a web-page is gzipped or compressed using Unix command line utility called curl? How do I make sure mod_deflate or mod_gzip is working under Apache web server?

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
Requirementscurl or wget
Estimated completion timeN/A

The mod_deflate or mod_gzip Apache module provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network. Most modern web browser support this feature. You can use the curl command to find out if a web page is gzipped or not using the the following simple syntax:

curl -I -H 'Accept-Encoding: gzip,deflate'


Type the following command:

curl -I -H 'Accept-Encoding: gzip,deflate'

Sample outputs:

HTTP/1.1 200 OK
Server: nginx
Date: Tue, 06 Nov 2012 18:59:26 GMT
Content-Type: text/html
Connection: keep-alive
X-Whom: l2-com-cyber
Vary: Cookie
Vary: Accept-Encoding
Last-Modified: Tue, 06 Nov 2012 18:51:58 GMT
Cache-Control: max-age=152, must-revalidate
Content-Encoding: gzip
X-Galaxy: Andromeda-1
X-Origin-Type: DynamicViaDAL

Curl command accept-encoding gzip bash test function

Create a bash shell function and add to your ~/.bashrc file:

gzipchk(){ curl -I -H 'Accept-Encoding: gzip,deflate' "$@" | grep --color 'Content-Encoding:'; }

Save and close the file. Reload ~/.bashrc file, run:
$ source ~/.bashrc file
Test the gzipchk() as follows:
$ gzipchk
Sample outputs:

Fig.01: Linux curl deflate gzip test in action

Fig.01: Linux curl deflate gzip test in action

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 1 comment… read it below or add one }

1 mitchell November 20, 2012 at 12:59 am

Adding the ‘-s’ switch to curl would instruct it not to print the progress meter.


Leave a Comment

Tagged as: , , , ,

Previous Faq:

Next Faq: