我有一个基于解析 apache 访问日志的服务,所以即使打开了 Vanish,我也需要在那里记录。
不,我只是简单地告诉 Varnish 不要缓存特定的 URL:
if (req.url ~ "(foo|bar)")
return(pass);
}
但是它占用大量资源,应该进行缓存。当 Varnish 将缓存副本返回给客户端时,是否可以将请求记录到 apache 访问日志中?
答案1
为什么不直接使用清漆记录器,并在清漆记录中增加命中或未命中的信息
https://www.varnish-cache.org/docs/trunk/reference/varnishncsa.html
看看下面的
%{X}x
Extended variables. Supported variables are:
Varnish:time_firstbyte
Time to the first byte from the backend arrived
Varnish:hitmiss
Whether the request was a cache hit or miss. Pipe and pass are considered misses.
Varnish:handling
How the request was handled, whether it was a cache hit, miss, pass, pipe or error.
VCL_Log:key
Output value set by std.log("key:value") in VCL.
默认情况下,它会将所有内容发送到标准输出。但你可以重定向它