在接收到完整的客戶端請求後調用這個子程序。它決定是否處理請求,怎樣處理請求,使用哪個後端。後端
它也可運用於修改請求,一些常常本身作的事情。緩存
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
在進入pipe模式時被調用。將請求直接傳遞至後端主機,並將後端響應原樣返回客戶端函數
vcl_pipe子程序能夠經過調用return()來結束,經過如下關鍵字:fetch
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模式處理
此函數在進入pass模式時被調用,用於將請求直接傳遞至後端主機,但後端主機的響應並不緩存直接返回客戶端;ui
vcl_pass子程序能夠經過調用return()來結束,經過如下關鍵字:spa
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將返回權威的默認錯誤。
在執行 lookup 指令後,在緩存中找到請求的內容後將自動調用該函數;rest
vcl_hit子程序能夠經過調用return()來結束,經過如下關鍵字:code
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. 返回一我的爲對象使用指定的狀態碼給客戶端或者放棄請求。
在執行 lookup 指令後,在緩存中沒有找到請求的內容時自動調用該方法,此函數可用於判斷是否須要從後端服務器獲取內容,從哪個後端獲取內容;orm
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_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.
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子程序能夠經過調用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子程序能夠經過調用return()來結束,經過如下關鍵字:
fetch Fetch the object from the backend. 從後端獲取對象 abandon Abandon the backend request and generates an error. 丟棄後端請求,同時生成一個錯誤頁面。
得到後端主機的響應後,可調用此函數;
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子程序能夠經過調用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中生成,不是從後端獲取。典型就是使用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加載時調用此函數,常常用於初始化varnish模塊(VMODs);
vcl_init子程序能夠經過調用return()來結束,經過如下關鍵字:
ok Normal return, VCL continues loading. 正常返回,VCL繼續加載。
當全部請求都離開當前VCL,且當前VCL被棄用時,調用此函數,常常用於清理varnish模塊;
vcl_init子程序能夠經過調用return()來結束,經過如下關鍵字:
ok Normal return, VCL will be discarded. 正常返回,VCL將再也不使用。