简介:This is Varnish Cache, a high-performance HTTP accelerator
varnish相关
varnish 相关文件路径
/etc/varnish/varnish.params: 配置varnish服务进程的工作特性,例如监听的地址和端口,缓存机制;
/etc/varnish/default.vcl:配置各Child/Cache线程的缓存策略;
varnish相关程序
/usr/sbin/varnishd 主程序
/usr/bin/varnishadm admin 管理工具
交互工具:
/usr/bin/varnishhist
/usr/bin/varnishlog
/usr/bin/varnishncsa
/usr/bin/varnishstat
/usr/bin/varnishtop
VCL配置文件重载程序:
/usr/sbin/varnish_reload_vcl
varnish程序的选项:(可以用varnishd -h查看)
-a address[:port][,address[:port][…],默认为6081端口;
-T address[:port],默认为6082端口;
-s [name=]type[,options],定义缓存存储机制;
-u user
-g group
-f config:VCL配置文件;
-F:运行于前台;
varnish程序运行流程
vcl_recv(收到请求), vcl_pass, vcl_hit, vcl_miss, vcl_pipe(非http协议–> pipe), vcl_purge, vcl_synth, vcl_deliver
VCL(”域“专有类型的配置语言)
VCL有多个状态引擎,状态之间存在相关性,但状态引擎彼此间互相隔离;每个状态引擎可使用return(x)指明关联至哪个下一级引擎;每个状态引擎对应于vcl文件中的一个配置段
例如:
vcl_hash --> return(hit) --> vcl_hit
vcl_recv的默认配置
vcl默认配置文件在builtin.vcl,会自动加载到default.vcl配置文件里
# sub vcl_recv {
# if (req.method == "PRI") {
# /* We do not support SPDY or HTTP/2.0 */
# return (synth(405));
# }
# if (req.method != "GET" &&
# req.method != "HEAD" &&
# req.method != "PUT" &&
# req.method != "POST" &&
# req.method != "TRACE" &&
# req.method != "OPTIONS" &&
# req.method != "DELETE") {
# /* Non-RFC2616 or CONNECT which is weird. */
# return (pipe);
# }
#