Created
July 27, 2011 10:09
-
-
Save timendum/1109067 to your computer and use it in GitHub Desktop.
Check if gzip is enabled [ http bash curl ]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
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