码迷,mamicode.com
首页 > 其他好文 > 详细

varnish 4.0 官方文档翻译14-Built in subroutines

时间:2015-06-15 19:00:14      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:

Built in subroutines

vcl_recv

在接收到完整的客户端请求后调用这个子程序。它决定是否处理请求,怎样处理请求,使用哪一个后端。

它也可运用于修改请求,一些经常自己做的事情。

vcl_recv子程序可以通过调用return()来结束,通过以下关键字:

synth(status code, reason)
    Return a synthetic object with the specified status code to the client and abandon the request.
    返回一个人为对象使用指定的状态码给客户端或者放弃请求。
pass
    Switch to pass mode. Control will eventually pass to vcl_pass.
    处理跳转到vcl_pass
pipe
    Switch to pipe mode. Control will eventually pass to vcl_pipe.
    处理跳转到vcl_pipe
hash
    Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.
    处理跳转到vcl_hash,在缓存中查找对象,如果有则为命中,
purge
    Purge the object and it‘s variants. Control passes through vcl_hash to vcl_purge.
    删除对象和它的变体。控制pass通过vcl_hash到vcl_purge

vcl_pipe

在进入pipe模式时被调用。将请求直接传递至后端主机,并将后端响应原样返回客户端

vcl_pipe子程序可以通过调用return()来结束,通过以下关键字:

synth(status code, reason)
    Return a synthetic object with the specified status code to the client and abandon the request.
    返回一个人为对象使用指定的状态码给客户端或者放弃请求。
pipe
    Proceed with pipe mode.
    使用pip模式处理

vcl_pass

此函数在进入pass模式时被调用,用于将请求直接传递至后端主机,但后端主机的响应并不缓存直接返回客户端;

vcl_pass子程序可以通过调用return()来结束,通过以下关键字:

synth(status code, reason)
    Return a synthetic object with the specified status code to the client and abandon the request.
    返回一个人为对象使用指定的状态码给客户端或者放弃请求。
fetch
    Proceed with pass mode.
    继续pass模式
restart
    Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.
    重新启动事务。增加了重新启动计数器。如果重新启动的次数比max_restarts高,varnish将返回权威的默认错误。

vcl_hit

在执行 lookup 指令后,在缓存中找到请求的内容后将自动调用该函数;

vcl_hit子程序可以通过调用return()来结束,通过以下关键字:

restart
    Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.
    重新启动事务。增加了重新启动计数器。如果重新启动的次数比max_restarts高,varnish将返回权威的默认错误。
deliver
    Deliver the object. Control passes to vcl_deliver.
    传递对象,使用vcl_deliver处理。
synth(status code, reason)
    Return a synthetic object with the specified status code to the client and abandon the request.
    返回一个人为对象使用指定的状态码给客户端或者放弃请求。

vcl_miss

在执行 lookup 指令后,在缓存中没有找到请求的内容时自动调用该方法,此函数可用于判断是否需要从后端服务器获取内容,从哪一个后端获取内容;

vcl_miss子程序可以通过调用return()来结束,通过以下关键字:

synth(status code, reason)
    Return a synthetic object with the specified status code to the client and abandon the request.
    返回一个人为对象使用指定的状态码给客户端或者放弃请求。
pass
    Switch to pass mode. Control will eventually pass to vcl_pass.
    处理跳转到vcl_pass
fetch
    Retrieve the requested object from the backend. Control will eventually pass to vcl_backend_fetch.
    从后端获取请求对象。控制最终传递到vcl_backend_fetch。
restart
    Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.
    重新启动事务。增加了重新启动计数器。如果重新启动的次数比max_restarts高,varnish将返回权威的默认错误。

vcl_hash

在vcl_recv调用后为请求创建一个hash值时,调用此函数;此hash值将作为varnish中搜索缓存对象的key;

vcl_hash子程序可以通过调用return()来结束,通过以下关键字:

lookup
    Look up the object in cache. Control passes to vcl_miss, vcl_hit or vcl_purge.
    从缓存中查找对象。控制传递至vcl_miss, vcl_hit 或者 vcl_purge.

vcl_purge

pruge操作执行后调用此函数,所有他的变种将被回避;

vcl_purge子程序可以通过调用return()来结束,通过以下关键字:

synth(status code, reason)
    Return a synthetic object with the specified status code to the client and abandon the request.
    返回一个人为对象使用指定的状态码给客户端或者放弃请求。
restart
    Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.
    重新启动事务。增加了重新启动计数器。如果重新启动的次数比max_restarts高,varnish将返回权威的默认错误。

vcl_deliver

将在缓存中找到请求的内容发送给客户端前调用此方法;

vcl_deliver子程序可以通过调用return()来结束,通过以下关键字:

deliver
    Deliver the object to the client.
    传递对象给客户端。
restart
    Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.
    重新启动事务。增加了重新启动计数器。如果重新启动的次数比max_restarts高,varnish将返回权威的默认错误。

vclbackendfetch

向后端主机发送请求前,调用此函数,可修改发往后端的请求;

vclbackendfetch子程序可以通过调用return()来结束,通过以下关键字:

fetch
    Fetch the object from the backend.
    从后端获取对象
abandon
    Abandon the backend request and generates an error.
    丢弃后端请求,同时生成一个错误页面。

vclbackendresponse

获得后端主机的响应后,可调用此函数;

vclbackendresponse子程序可以通过调用return()来结束,通过以下关键字:

deliver
    Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.
    可以将对象插入到缓存,然后传递它到控制器,最终传递到vcl_deliver。
abandon
    Abandon the backend request and generates an error.
    丢弃后端请求,同时生成一个错误页面。
retry
    Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.    
    重新启动事务。增加了重新启动计数器。如果重新启动的次数比max_restarts高,varnish将返回权威的默认错误。

vclbackenderror

当从后端主机获取源文件失败时,调用此函数;

vclbackenderror子程序可以通过调用return()来结束,通过以下关键字:

deliver
    Deliver the error.
    传递错误页面
retry
    Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.
    重新启动事务。增加了重新启动计数器。如果重新启动的次数比max_restarts高,varnish将返回权威的默认错误。

vcl_synth

调用是返回一个定义的的对象,定义的对象在VCL中生成,不是从后端获取。典型就是使用synthetic()函数;

vcl_synth子程序可以通过调用return()来结束,通过以下关键字:

deliver
    Deliver the object. If the object has a positive TTL then the object is also stored in cache.
    传递对象,如果对象设置了TTL,该对象还会存储如缓存中。
restart
    Restart processing the object.
    重新启动对对象的处理。

vcl_init

VCL加载时调用此函数,经常用于初始化varnish模块(VMODs);

vcl_init子程序可以通过调用return()来结束,通过以下关键字:

ok
    Normal return, VCL continues loading.
    正常返回,VCL继续加载。

vcl_fini

当所有请求都离开当前VCL,且当前VCL被弃用时,调用此函数,经常用于清理varnish模块;

vcl_init子程序可以通过调用return()来结束,通过以下关键字:

ok
    Normal return, VCL will be discarded.
    正常返回,VCL将不再使用。


varnish 4.0 官方文档翻译14-Built in subroutines

标签:

原文地址:http://my.oschina.net/monkeyzhu/blog/467055

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!