歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> varnish 4.0官方文檔翻譯 Built in subroutines

varnish 4.0官方文檔翻譯 Built in subroutines

日期:2017/2/27 15:48:38   编辑:Linux教程

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將不再使用。
Copyright © Linux教程網 All Rights Reserved