通过标题调试清漆

时间:2015-09-02 14:01:59

标签: varnish varnish-vcl

Varnish(快速运行)缓存对象的时间比I(我认为)指定的时间长。要调试此问题,我可以通过以下方式在任何地方添加标题:

sub vcl_miss {
  set req.http.Debugmiss = "vcl_miss";
#FASTLY miss
  return(fetch);
}
sub vcl_deliver {
#FASTLY deliver
  set resp.http.Debugmiss = req.http.Debugmiss;
  return(deliver);
}

我已为vcl_recvvcl_hitvcl_missvcl_passvcl_hashvcl_fetch执行此操作;但是,似乎根据标题调用的唯一函数是vcl_recv(执行查找)和vcl_deliver。例如,根据vcl_recv返回lookup代码后的状态图(https://www.varnish-software.com/book/3/_images/vcl.png),应调用vcr_hash函数。如果是,它似乎没有设置任何标题。

有什么我可以忽略的吗?

这些是curl返回的响应头:

< HTTP/1.1 200 OK
< Server: Cowboy
< X-Frame-Options: SAMEORIGIN
< X-Xss-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Etag: W/"9fbfd39142780bd83fed663b051c83d9"
< X-Request-Id: a2a9b83a-4143-4b40-b788-94969dd5ce91
< X-Runtime: 0.020195
< X-Rack-Cache: miss
< Via: 1.1 vegur
< Content-Length: 434
< Accept-Ranges: bytes
< Date: Wed, 02 Sep 2015 13:41:41 GMT
< Via: 1.1 varnish
< Age: 4
< Connection: keep-alive
< X-Served-By: cache-lhr6332-LHR
< X-Cache: HIT
< X-Cache-Hits: 1
< X-Timer: S1441201301.048931,VS0,VE2
< Cache-Control: no-cache, no-store, private, must-revalidate, max-age=0, max-stale=0, post-check=0, pre-check=0
< Expires: 0
< Pragma: no-cache
< Debugrecv: vcl_recv
< Debugrecvreturn: lookup
< debugme: vcl_deliver; desperate8

可以在此处找到整个vcl:https://gist.github.com/mdemare/2e0fa52e62691806e0a0

1 个答案:

答案 0 :(得分:1)

我认为问题出在vcl函数中,其中为req 设置了标头,这是请求对象,而不是响应。因此,当查看响应标题时,设置为req对象的那些将不会显示。

您可以尝试查看请求标头,也可以使用varnishlog(more info