squid回源选择配置方法小结

发布时间:2019-12-18编辑:脚本学堂
本文介绍的内容,一共关系到cache_peer/always_direct/never_direct/hierarchy_stoplist/prefer_direct等配置项。

squid的使用指南上,关于always_direct和never_direct这么写到:
Squid checks all always_direct tags before it checks any never_direct tags. If a matching always_direct tag is found, Squid will not check the never_direct tags, but decides which cache to talk to immediately…. If the line used the deny keyword instead of allow, Squid would have simply skipped on to checking the never_direct lines

squid的配置说明上,关于hierarchy_stoplist这么写到:
use this to not query neighbor caches for certain objects….never_direct overrides this option

squid的邮件列表上,Amos这么解释:
always_direct prevents peers being used. It does not force them. “ hierarchy_stoplist ? “ is the directive preventing the peer being used.

大致意思就是:
always_direct allow的优先级高于never_direct,但deny(包括allow !)时则不。
hierarchy_stoplist强制请求通过域名解析回源,但never_direct又优先于它。
prefer_direct用于所有cache_peer都down了时,never_direct会报错,而prefer会转入dns解析。