varnish.vcl :

    # Compression filter. See https://www.varnish-cache.org trac/wikiFAQCompression
            if (req.http.Accept-Encoding) {
Line 82 ---- >  if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
                    # No point in compressing these
                    unset req.http.Accept-Encoding;
                } elsif (req.http.Accept-Encoding ~ "gzip") {
                    set req.http.Accept-Encoding = "gzip";
                } elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") {
                    set req.http.Accept-Encoding = "deflate";
                } else {
                    # unknown algorithm
                    unset req.http.Accept-Encoding;

1 Answer 1


The short answer is yes.

But the long answer is: this snippet is obsolete since Varnish 4.x, because it already does Accept-Encoding normalization internally.

So removing it is best, unless you're using old Varnish like v3.

From the docs:

Unless returning from vcl_recv with pipe or pass, Varnish modifies req.http.Accept-Encoding: if the client supports gzip req.http.Accept-Encoding is set to "gzip", otherwise the header is removed.

I really don't know why everyone is so late on picking up that change.. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.