Search This Blog

2013-05-12

Squid配置注意事项

以前一个项目遇到过一个问题:给服务器部署新版本之后,在几分钟之内,用户看到的某个页面都是错误页面。Web服务器有一点错误日志(证明确实有错),后续访问都没有错误日志,看Squid日志,发现一些TCP_NEGATIVE_HIT/500。

当时用的是Squid 2.6,动态页面跟错误页面都缓存了,这两个必须避免。
下面是当时记录的文档:
TCP_NEGATIVE_HIT
When a request to an origin server results in an HTTP error, Squid may cache the response anyway. Repeated requests for these resources, within a short amount of time, result in negative hits. The negative_ttl directive controls the amount of time these errors may be cached. Also note that errors are cached only in memory and never written to disk. The following HTTP status codes may be negatively cached, subject to additional constraints: 204, 305, 400, 403, 404, 405, 414, 500, 501, 502, 503, 504.
可以用negative_ttl设置错误页面的生存时间。negative_ttl的文档在http://www.squid-cache.org/Doc/config/negative_ttl/,现在的默认值已经是0了。

=文章版本=

20130512

No comments:

Post a Comment