caching清漆中的所有文件

我想让我的清漆服务器caching所有文件。 在后端有lighttpd仅托pipe静态文件,并且在文件更改的情况下,在URL中有一个md5/gfx/Bird.b6e0bc2d6cbb7dfe1a52bc45dd2b05c4.swf )。 但是我的命中率很差(大约0.18)

我的configuration:

 sub vcl_recv { set req.backend=default; ### passing health to backend if (req.url ~ "^/health.html$") { return (pass); } remove req.http.If-None-Match; remove req.http.cookie; remove req.http.authenticate; if (req.request == "GET") { return (lookup); } } sub vcl_fetch { ### do not cache wrong codes if (beresp.status == 404 || beresp.status >= 500) { set beresp.ttl = 0s; } remove beresp.http.Etag; remove beresp.http.Last-Modified; } sub vcl_deliver { set resp.http.expires = "Thu, 31 Dec 2037 23:55:55 GMT"; } 

我做了一个性能调整:

 DAEMON_OPTS="${DAEMON_OPTS} -p thread_pool_min=200 -p thread_pool_max=4000 -p thread_pool_add_delay=2 -p session_linger=100" 
  1. 错过的主要url是… /health.html。 那是否正确configuration后端?
  2. 禁用健康检查命中率增加到0.45。 现在主要是“/crossdomain.xml”(从许多域,因为它是通配符)错过了。 我怎样才能避免呢?
  3. 我应该进行其他头像User-Agent或Accept-Encoding? 我默认的哈希机制是使用url + host / IP。 压缩在后端使用。
  4. 还有什么可以提高性能?

需要更多的信息(轻微的响应标题),但我会假设你的后端没有设置过期或caching控制标题。

这是必需的,所以Varnish知道将数据存储在caching中需要多长时间,或者也可以通过-t default_ttl_in_seconds指定DAEMON_OPTS中的默认ttl。

或者确实在VCL本身,如在这里回答: Varnish Cache – 默认的TTL?

然而,这又假定你的后端光服务器在过去没有返回过期,并且不返回caching前caching的caching控制头(即no-cache,必须重新validationiirc),如果是这种情况设置默认TTL将无济于事缓解这个问题。