cURL Tip: Check that the Apache Compression (gzip, deflate) is Working

terminal-logo-smallThis is a quick method with using cURL to check that Apache Compression with mod_gzip and mod_deflate is working. Only the remote server headers are needed.

Check that the Apache Compression is Working

Get headers

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

-I option which will make just HEAD request to server and get headers.
-H option add header for accecpt content-encondig gzip and deflate.

Check headers

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

If gzip or deflate found from headers then compression is working.

Simple bash function to check Apache compression

Create function (add following to ~/.bashrc)

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

Function usage

[root ~]> check_compression http://www.if-not-true-then-false.com/wp-content/themes/snowblind/style.css
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  3203    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Content-Encoding: gzip
 
[root ~]> check_compression http://www.if-not-true-then-false.com/wp-content/plugins/wp-minify/min/?f=/wp-content/themes/snowblind/style.css
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  2165    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Content-Encoding: deflate

Related posts:

  1. Howto hide and modify Apache server information (ServerSignature and ServerTokens) and Hide PHP version (X-Powered-By) By default almost all Apache installation shows sensitive server information with Apache version number, server operating system details, installed Apache...
  2. PHP mb_ucfirst Make a String’s First Character Uppercase-Multibyte (UTF-8) Function PHP’s ucfirst function is very usefull when you want to change words first letters to uppercase and other letters to...
  3. Google search from Linux and UNIX command line Today I started thinking that how cool is do some Google searches straight from command line. First I try to...
  4. Install Apache (httpd) and PHP 5.3.3 on Fedora 13, CentOS/RHEL 5.5/6 This guide shows howto install Apache HTTP Server (httpd) with PHP 5.3.3 and following modules: PEAR PDO MySQL PostgreSQL Memcache...
  5. LAMP on Fedora 13, CentOS/Red Hat (RHEL) 5.5/6 – (Linux, Apache, MySQL, PHP) LAMP (Linux, Apache, MySQL, PHP) server is very powerful server setup behind any website or web based service. This guide...

About the Author

Hi, I'm JR and the Founder of if not true then false. I am a software developer, and I have over ten years experience in programming. I'm big fan of Linux and Open Source. And normally I use just Linux environments. - You can follow me on Twitter at @zuissi