7

# Example code GZIP

    my $r = shift;
    ...
    my $content = qq{<HTML><HEAD>...
    </BODY></HTML>
    };
    if (accepts_gzip($r)) {
      require Compress::Zlib;
      $r->header_out('Content-Encoding', 'gzip');
      $content = Compress::Zlib::memGzip($content);
    }
    ...
    $r->header_out('Vary', 'accept-encoding');
    sub accepts_gzip { # naïve approach
      my $r = shift;
      $r->header_in("Accept-Encoding") =~ m|\bgzip\b|i;
    }