什么是清漆中的管道模式和通过模式

J-D*_*J-D 9 varnish varnish-vcl

什么是管道模式和传递模式在varnish-cache ...我一直试图参考这个链接来理解清漆.我有点理解通过,但我想要一个更好的解释.. http://spin.atomicobject.com/2013/01/16/speed-up-website-varnish/

Bra*_*ldt 27

传递模式在Varnish中很常见,只是告诉Varnish将请求传递给后端而不是尝试从缓存中提供它.这用于不应缓存的动态页面.例:

sub vcl_recv {
    if (req.url ~ "^/myprofile") {
        return (pass)
    }
}
Run Code Online (Sandbox Code Playgroud)

管道模式完全不同,很少使用.如果要流式传输对象(如视频),则需要使用管道来避免超时.使用pipeVarnish意味着停止检查每个请求,并直接将字节发送到后端.使用管道时有多个陷阱,因此请务必使用 Varnish文档中的管道进行结帐.

例:

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";
}
Run Code Online (Sandbox Code Playgroud)