转载本站文章请注明,转载自: 月影鹏鹏 [http://Jacky.Aiwaly.com]
本文链接: http://jk.aiwaly.com/wp/varnish-%e5%85%81%e8%ae%b8%e5%ae%a2%e6%88%b7%e7%ab%af%e5%bc%ba%e5%88%b6%e6%9b%b4%e6%96%b0.html
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;
}