terminal-logo-small

This is a quick method to check with using cURL that Nginx/Apache (or any other web server) compression with Nginx ngx_http_gzip_module (gzip), Nginx google/ngx_brotli (br), Apache mod_brotli (br), Apache mod_gzip (gzip) and Apache mod_deflate (deflate) is working. Only the remote server headers are needed.

Check that the Nginx/Apache Compression is Working

Get headers

curl -s -I -H 'Accept-Encoding: br,gzip,deflate' https://www.if-not-true-then-false.com

-s option silent, disable progress bar.
-I option which will make just HEAD request to server and get headers.
-H option add header for accept content-encoding br, gzip and deflate.

Check headers

### Working ###
[...]
Content-Encoding: br
[...]
### Working ###
[...]
Content-Encoding: gzip
[...]
### Working ###
[...]
Content-Encoding: deflate
[...]
### Not working ###
[...]
[...]

If br, gzip or deflate found from Content-Encoding: headers then compression is working.

If you want just check example a gzip encoding, then run following command:

curl -I -H 'Accept-Encoding: gzip' https://www.if-not-true-then-false.com

Simple BASH functions to check Nginx/Apache compression

Add following functions to ~/.bashrc

Function to Check Brotli (br), Gzip and Deflate comperession

function check_compression {
  curl -s -I -H 'Accept-Encoding: br,gzip,deflate' $1 |grep -i "Content-Encoding"
}

Function to Check Just Gzip Compression

function check_gzip_compression {
  curl -s -I -H 'Accept-Encoding: gzip' $1 |grep -i "Content-Encoding"
}

Function usage

[root ~]> check_compression https://www.if-not-true-then-false.com/wp-content/themes/inttf/js/prism.js
Content-Encoding: br

[root ~]> check_gzip_compression https://www.if-not-true-then-false.com/wp-content/themes/inttf/js/prism.js
Content-Encoding: gzip