Q:如何配置varnish緩存到硬盤?
A:http://softbeta.iteye.com/blog/1681716
Q:如果debug VCL?
A:http://stackoverflow.com/questions/12576248/how-to-debug-vcl-in-varnish
Q:怎樣不重啟varnish讓新的vcl生效?
A:用varnishadm進入管理員頁面:
Shell代碼

- vcl.load <configname> <filename> //加載一個新的vcl配置,configname:給配置起個名字,filename:配置的路徑
- vcl.use <configname> //使用新的配置
- vcl.discard <configname> // 刪除某個配置
- vcl.list //查看所有加載的配置
Q:VCL怎么urlrewrite?
A:https://www.varnish-cache.org/trac/wiki/RedirectsAndRewrites
PS:regsub函數支持后向引用(backreferences)。
eg:
Vcl代碼

- set req.url = regsub(req.url,"/attachment/(.+)(&token=.+)$","/cache/attachment/\1");
Q:503 service unavailable?
A:503錯誤,這是因為varnish對后端服務器響應header有限制,默認長度是2048,可將其調大一些
啟動參數代碼

- -p http_resp_hdr_len=8192
VCL官方文檔:https://www.varnish-cache.org/docs/3.0/reference/vcl.html