Skip to content
add the gzip feature to squid-2.7 on the fly
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This patch adds the feature of http compression on the fly for squid-2.7


This patch is at its very early phase of development and considered
highly experimental. But you're encouraged to test it out on your side
and report any quirks that you experience.

We need your help! If you find this module useful and/or interesting,
please consider joining the development!


Get the squid-2.7 source from
Get the patch from

cd squid-2.7
patch -p1 < /path/to/http_gzip.patch

compile squid with the following command:

./ && ./configure --enable-http-gzip && make

I have tested in accelerator mode.
http_gzip on
http_gzip_types text/html,text/plain

    syntax: http_gzip on|off
    default: on
    context: main
    description: switch the http compression 

    syntax: http_gzip_prefer_gzip on|off
    default: on
    context: main
    description: sends gzip content to user agents who can accept both 
    gzip and deflate content.

    syntax: http_gzip_prefer_deflate on|off
    default: on
    context: main
    description: sends deflate content to user agents who can accept 
    both gzip and deflate content. If prefer_deflate and perfer_gzip are
    both on. deflate is higher priority than gzip.

    syntax: http_gzip_types [mime types]
    default: text/html
    context: main
    description: This directive set the MIME types list which need to be 
    compressed. The types need be separated by ',' and there should not 
    be any space between types.

    syntax: http_gzip_hash memLevel
    default: 8
    context: main
    description: The memlevel parameter specifies how much memory should be
    allocated for the internal compression state. memLevel=1 uses minimum memory
    but is slow and reduces compression ratio; memLevel=9 uses maximum memory
    for optimal speed. 

    syntax: http_gzip_comp_level level
    default: 9
    context: main
    description: The compression level, between 1 and 9, where 1 is the 
    least compression (fastest) and 9 is the most (slowest).

    syntax: http_gzip_min_length length
    default: 0
    context: main
    description: Sets the minimum length of of the response that will be
    compressed. Responses shorter than this will not be compressed. Length is
    determined from the "Content-Length" header.

    syntax: http_gzip_window windowBits
    default: 15
    context: main
    description: The windowBits parameter is the base two logarithm of the
    window size (the size of the history buffer). It should be in the range
    8..15 for this version of the library. Larger values of this parameter
    result in better compression at the expense of memory usage. 

    syntax: http_gzip_prealloc size
    default: 256 KB
    context: main
    description:  We preallocate a memory for zlib in one buffer (default:
    256K), this decreases a number of malloc() and free() calls and also
    probably decreases a number of syscalls (sbrk()/mmap() and so on).



Copyright (c) 2010, Netease Inc. ( ).

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License (version 2) as
published by the Free Software Foundation.  It is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
PURPOSE.  See the GNU General Public License for more details.

Questions/patches may be directed to Weibin Yao,
You can’t perform that action at this time.