Varnish用法详解

简介: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);
#     }
# 
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值