varnish 允许客户端强制更新

January 17th, 2010 by jacky Leave a reply »

varnish 允许客户端强制更新

varnish   Enable force-refresh from clients

当接收来自客户端的“强制刷新”的要求,这个配置会从后端服务器提取内容要求,更新缓存,并提供给客户。

对于大型缓存,履行不从客户缓存请求最好的处理是通过设置在vcl_hit obj.ttl = 0和重新启动的要求。这是最好调用您的VCL purge_url,因为它避免了建立一个大型清洗名单和可能耗尽内存资源。

看到这个细节上的邮件列表的讨论。

When receiving a “force-refresh” request from a client, this configuration will fetch the requested element from the backend, update the cache and deliver it to the client.

For large caches, honouring no-cache requests from the client is best handled by setting obj.ttl = 0s in vcl_hit and restarting the request. This is preferable to calling purge_url in your VCL because it avoids building up a large purge list and potentially exhausting memory resources.

See this discussion on the mailing list for details.

sub vcl_hit {
    if (!obj.cacheable) {
        pass;
    }

    if (req.http.Cache-Control ~ "no-cache") {
        # Ignore requests via proxy caches,  IE users and badly behaved crawlers
        # like msnbot that send no-cache with every request.
        if (! (req.http.Via || req.http.User-Agent ~ "bot|MSIE")) {
            set obj.ttl = 0s;
            return (restart);
        }
    }
    deliver;
}
当接收来自客户端的“力量,刷新”的要求,这个配置会撷取从后端要求元素,更新缓存,并提供给客户。
Advertisement

Leave a Reply