# BasicTo Varnish Config

# VCL

# 常用代码块

#定义后端主机
backend default {
  .host = "172.16.2.14";  #后端主机地址
  .port = "80"; #后端主机监听端口
}

#定义缓存命中状态
sub vcl_deliver {
  if (obj.hits > 0) {
    # 如果缓存命中次数大于0
    set resp.http.X-Cache = "HIT";
  } else {
    set resp.http.X-Cache = "MISS";
  }
  return (deliver);
}


sub vcl_backend_response {
  # 设置缓存过期时间
  set beresp.ttl = 45s;
}
陕ICP备20004732号-3