Skip to content

Instantly share code, notes, and snippets.

@timendum
Created July 27, 2011 10:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save timendum/1109067 to your computer and use it in GitHub Desktop.
Save timendum/1109067 to your computer and use it in GitHub Desktop.
Check if gzip is enabled [ http bash curl ]
curl -I -H "Accept-Encoding: gzip,deflate" "$URL" --silent | grep -i "Content-Encoding:"
# OR
curl -H "Accept-Encoding: gzip,deflate" "$URL" --silent --write-out "%{size_download}" --output /dev/null
curl "$URL" --silent --write-out "%{size_download}" --output /dev/null
# 2nd must be greater the 1st
@teuf22
Copy link

teuf22 commented Oct 9, 2018

The first version didn't work for me on some sites. The problem is that -I sends a HEAD request. Some sites may not compress their reply to HEAD even though they have gzip enabled. Another solution is:
curl -sD - -o /dev/null http://example.com
https://stackoverflow.com/a/26644485/960857

@Feriman22
Copy link

Feriman22 commented Jun 4, 2020

This version is working for me:

curl -H "Accept-Encoding: gzip" -i https://blogginger.com 2>/dev/null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment