Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | No |
Requirements | curl or wget |
Time | 1m |
curl command syntax to find if a website using gzip / deflate encoding
The syntax is:
curl -I -H 'Accept-Encoding: gzip,deflate' https://domain-name
## OR ##
curl -s -I -L -H 'Accept-Encoding: gzip,deflate' https://domain-name
## OR ##
curl -s -I -L -H 'Accept-Encoding: gzip,deflate' https://domain-name | grep -i '^content-encoding'
Where,
- -s – Don’t show progress meter or error messages.
- -I – Work on the HTTP-header only.
- -H 'Accept-Encoding: gzip,deflate' – Send extra header in the request when sending HTTP to a server.
- -L – f the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place.
- https://domain-name – Your URL, it can start with http or https.
Examples
Type the following command:
curl -I -H 'Accept-Encoding: gzip,deflate' http://www.cyberciti.biz/ curl -I -H 'Accept-Encoding: gzip,deflate' https://www.cyberciti.biz/
Here
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 to test accept-encoding/compression gzip bash test function
Create a bash shell function and add to your ~/.bashrc file:
# add to your shell statup gzipchk(){ curl -I -H 'Accept-Encoding: gzip,deflate' "$@" | grep --color -i 'Content-Encoding:'; }
OR use the silent mode to hide progress bar:
# add to your ~/.bashrc # this version check for both gzip and brotli compression gzipchk(){ curl -sILH 'Accept-Encoding: gzip,deflate,br' "$@" | grep --color -i 'Content-Encoding:'; }
Save and close the file. Reload ~/.bashrc file, run:
$ source ~/.bashrc file
Test the gzipchk() as follows:
$ gzipchk www.cyberciti.biz
$ gzipchk https://www.redhat.com
Linux curl deflate gzip test in action
Checking if your web server is sending the Brotli or gzip compression response
In short we use the following curl command:
curl --sILH 'Accept-Encoding: gzip,deflate,br' your-website-here
## or filter out using the grep command ##
DOM="your-website-here"
curl --sILH 'Accept-Encoding: gzip,deflate,br' $DOM |\
grep -i --color '^Content-Encoding:'
Use wget to check if a website using gzip / deflate / brotli compression
We can use the wget command too as follows when curl is not installed on your system to find out if a website web server using gzip/deflate compression as follows:
DOMAIN="https://www.cyberciti.biz" wget -O /dev/null --server-response \ --header "Accept-Encoding: gzip,deflate,br" \ $DOMAIN # another example # wget -O /dev/null --server-response \ --header "Accept-Encoding: gzip,deflate,br" $DOMAIN 2>&1 |\ grep --color -i 'Content-Encoding:'
Conclusion
With the curl command line-tool, you can quickly check if your web server is sending the Gzip compressed payload to your web browser. No need to use 3rd party website as curl is installed on Linux, macOS, *BSD and Unix-like systems.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 1 comment... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Adding the ‘-s‘ switch to curl would instruct it not to print the progress meter.