What is Pipe mode and pass mode in varnish

J-D picture J-D · Mar 19, 2014 · Viewed 11.7k times · Source

what is pipe mode and pass mode in varnish-cache ... I have been trying to refer to this link to understand varnish. I somewhat understand pass but I'd like a better explanation.. http://spin.atomicobject.com/2013/01/16/speed-up-website-varnish/

Answer

Brandon Wamboldt picture Brandon Wamboldt · Apr 14, 2014

Pass mode is very common in Varnish, and just tells Varnish to pass the request to the backend rather than try and serve it from cache. This is used for dynamic pages that should not be cached. Example:

sub vcl_recv {
    if (req.url ~ "^/myprofile") {
        return (pass)
    }
}

Pipe mode is quite different and is rarely used. If you want to stream objects, such as videos, you'll want to use pipe to avoid timeouts. Using pipe means Varnish stops inspecting each request, and just sends bytes straight to the backend. There are multiple gotchas when using pipe, so be sure to checkout using pipe in the Varnish docs.

Example:

sub vcl_recv {
    if (req.url ~ "^/video/stream/") {
        return (pipe)
    }
}

sub vcl_pipe {
    # http://www.varnish-cache.org/ticket/451
    # This forces every pipe request to be the first one.
    set bereq.http.connection = "close";
}