How to test if mod_gzip is working

Help
Sam Snow
2003-04-06
2013-04-08
  • Sam Snow
    Sam Snow
    2003-04-06

    I have heard of two ways of testing if mod_gzip is working on your web server:

    1. Turn "mod_gzip_keep_workfiles     Yes" and then look at the "mod_gzip_temp_dir" and see if files are created. Be sure to change "mod_gzip_keep_workfiles" back to no once you have completed testing.

    2. Use the web-based tester at http://leknor.com/code/gziped.php .

    Does anyone have any other methods?

    Sam

     
    • victor
      victor
      2003-11-20

      i found this code somewhere, added some changes and here it is
      very simple ...

      #!/usr/bin/perl
      use Socket;

      if(@ARGV ne 1) {
          print "\nUsage: mod_gzip_test http://your_site.com/yourpage.html\n\n";
              exit;
              }

              $ARGV[0] =~ /http:\/\/(.*)\/(.*)/i;

              $in_addr = (gethostbyname($1))[4];
              $port = 80;
              $addr = sockaddr_in($port, $in_addr);
              $proto = getprotobyname('tcp');

              socket(S, AF_INET, SOCK_STREAM, $proto) or die;
              connect(S, $addr) or die;
              select(S); $| = 1; select(STDOUT);

              print S "GET /$2 HTTP/1.1\nHost: $1\nAccept-Encoding: gzip\nUser-Agent: mod_gzip_test\n\n";

              while(<S>) {
                  if(length($_) < 3) { print "$1\n $2\n No compression used.\n"; exit; }
                      if(/Content-Encoding: gzip/i) {
                              print ("Page was sent GZIP compressed.\n"); exit;
                                  }
                                  }

       
    • victor
      victor
      2003-11-20

      you can also check http://yoursite/mod_gzip_status/

      this may vary deppending on your mod_gzip settings.

       
    • Ken Fong
      Ken Fong
      2008-12-19

      curl --compressed -v -o/dev/null http://your.domain.tld/some/page

      then look for "Content-Encoding: gzip"

      Do not use the --head option as HEAD requests will not be compressed.