Varnish VMOD: compress and uncompress (gzip/gunzip) directly in VCL
M4 C Shell Makefile
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
m4
src
.gitignore
.travis.yml
LICENSE
Makefile.am
README.rst
autogen.sh
configure.ac

README.rst

vmod-zlib

https://travis-ci.org/thomsonreuters/libvmod-zlib.svg?branch=master

SYNOPSIS

import zlib;

DESCRIPTION

ZLIB vmodule for Varnish 4 and 5. libvmod-zlib uncompress request's body before sending it to the backend. E.g. it is useful when backends doesn't support compression. Also, It could be used to reduce backend's CPU load but note that it will impact network bandwidth and delay. Use it only for particular use-cases.

FUNCTIONS

unzip_request()

Uncompress the request's body in vcl_recv when Content-Encoding is set to gzip. No operation if Content-Encoding is unset or none.

USAGE

In your VCL you could then use this vmod along the following lines:

import zlib;

sub vcl_recv {
        if (zlib.unzip_request() < 0) {
            return (synth(400, "can't uncompress request's body"));
        }
}

Note that VMOD allocates the size of gzip_buffer bytes in the workspace_client. In order to work properly, you must increase the default size of workspace_client which is too low by default. (gzip_buffer and http_req_size are already taking the full space).