gzip not working in Varnish 4.1

Miguel González miguel_3_gonzalez at yahoo.es
Thu Nov 10 19:52:15 CET 2016


Dear all,

  I have read in the docs that enabling in varnishd http_gzip_support:

  -p http_gzip_support=true


   it should compress the content but testing with curl -I -H
'Accept-Encoding:gzip' is not reporting gzip.

   My vcl backend_response is below, do I need to set somewhere
beresp.do_gzip = true even when I set it for varnishd?

  Regards,

  Miguel


-----------------------------------------------------------------------------------------------

   sub vcl_backend_response {
        # Remove some headers we never want to see
        unset beresp.http.Server;
        unset beresp.http.X-Powered-By;

        # For static content strip all backend cookies
        if (bereq.url ~ "\.(css|js|png|gif|jp(e?)g)|swf|ico") {
                unset beresp.http.cookie;
        }
        # Don't store backend
        if (bereq.url ~ "wp-(login|admin)" || bereq.url ~ "preview=true") {
                set beresp.uncacheable = true;
                set beresp.ttl = 30s;
                return (deliver);
        }

        # Only allow cookies to be set if we're in admin area
                if (!(bereq.url ~
"(wp-login|cart|my-account|checkout|addons|tienda|carro|wp-admin|preview=true)"))
{
                unset beresp.http.set-cookie;
        }

        # don't cache response to posted requests or those with basic auth
        if ( bereq.method == "POST" || bereq.http.Authorization ) {
                set beresp.uncacheable = true;
                set beresp.ttl = 120s;
                return (deliver);
        }

        # don't cache search results
        if ( bereq.url ~ "\?s=" ){
                set beresp.uncacheable = true;
                set beresp.ttl = 120s;
                return (deliver);
        }

        # only cache status ok
        if ( beresp.status != 200 ) {
                set beresp.uncacheable = true;
                set beresp.ttl = 120s;
                return (deliver);
        }

        # A TTL of 24h
        set beresp.ttl = 24h;
        # Define the default grace period to serve cached content
        #set beresp.grace = 30s;
        set beresp.grace = 1h;

        return (deliver);
}




More information about the varnish-misc mailing list