标签:
VCL中有些需要你注意的重要对象。这些对象可以在VCL被使用和操作。
req The request object. When Varnish has received the request the req object is created and populated. Most of the work you do in vcl_recv you do on or with the req object. 请求对象。当vanish接收到请求后,req对象被创建和生成。你可以在vcl_recv中使用req对象做很多事。 bereq The backend request object. Varnish contructs this before sending it to the backend. It is based on the req object. 后端请求对象。varnish在发送请求到后端之前构建这个对象。它基于req对象。 beresp The backend response object. It contains the headers of the object coming from the backend. If you want to modify the response coming from the server you modify this object in vcl_backend_response. 后端响应对象。它包含在从后端响应对象的头里。如果你想修改后端server返回的响应信息,你可以在vcl_backend_response中修改beresp对象。 resp The HTTP response right before it is delivered to the client. It is typically modified in vcl_deliver. 传递给客户端响应之前的response对象。通常在vcl_deliver中修改。 obj The object as it is stored in cache. Read only. 存储在缓存中的对象。 只读。
最常见的动作return这些:
pass When you return pass the request and subsequent response will be passed to and from the backend server. It won‘t be cached. pass can be returned from vcl_recv. 当你在子程序中return(pass)请求和随后的响应将被传递到后端server和从后端server回传回来。响应将不会被缓存。pass可以从vcl_recv中返回。 hash When you return hash from vcl_recv you tell Varnish to deliver content from cache even if the request othervise indicates that the request should be passed. 在*vcl_recv*中return(hash),通知varnish从cache查找请求内容,除非这个请求不被标示,那么请求应当被pass。 pipe .. XXX:What is pipe? benc Pipe can be returned from vcl_recv as well. Pipe short circuits the client and the backend connections and Varnish will just sit there and shuffle bytes back and forth. Varnish will not look at the data being send back and forth - so your logs will be incomplete. pipe也可以在*vcl_recv*中返回,return(pipe)。 deliver Deliver the object to the client. Usually returned from vcl_backend_response. 传递对象给客户端。通常在vcl_backend_response中return。 restart Restart processing of the request. You can restart the processing of the whole transaction. Changes to the req object are retained. 重新对请求进行处理。你可以在整个请求处理的阶段重启。更改过的req对象将被保留。 retry Retry the request against the backend. This can be returned from vcl_backend_response or vcl_backend_error if you don‘t like the response that the backend delivered . 重启指向后端的请求。如果你不想从后端获得响应,你可以在vcl_backend_response 或者vcl_backend_error 中return。
varnish 4.0 官方文档翻译15- VCL objects/actions
标签:
原文地址:http://my.oschina.net/monkeyzhu/blog/467267