[CDN 技术] 404的http头在squid中的处理

Sep 18th, 2008

转载本站文章请注明,转载自:扶凯[http://www.php-oa.com]

本文链接: http://www.php-oa.com/2008/09/18/404%e7%9a%84http%e5%a4%b4%e5%9c%a8squid%e4%b8%ad%e7%9a%84%e5%a4%84%e7%90%86.html

 

404的网页在squid中也会被缓存,会出现TCP_NEGATIVE_HIT:NONE www.php-oa.com这样的日志,可以用
negative_ttl 的参数来控制时间,默认5分钟,有点长,建议小点

Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪 ViVi 365Key 网摘 天极网摘 和讯网摘 博拉网 POCO 网摘 饭否 QQ 书签 Digbuzz 我挖网 Mister Wong
Tags: , ,
  1. badboy
    Oct 13th, 2008 at 08:48
    Reply | Quote | #1

    由于页面问题或web服务器临时不可用,会导致squid缓存一个错误信息(400,500等错误),正好是首页出错并被老板发现了。。。。
    如何不缓存这些错误页面呢?

    要想不缓存错误页面据说可以设成negative_ttl 1 second

  2. admin
    Oct 13th, 2008 at 09:58
    Reply | Quote | #2

    其实在squid3.0中直接可以让squid不缓存400和302之类的网页。但是squid3.0还非常不稳定,不建议使用,最好是能给404和302之类的网页加直接过期的http头

  3. badboy
    Oct 13th, 2008 at 11:31
    Reply | Quote | #3

    将negative_ttl 1 second去掉,

    为何不行?难道apache的规则,优先与网页添加的头,apache的头部规则将网页加的这条规则覆盖掉了?

  4. gzmaster
    Nov 4th, 2008 at 16:16
    Reply | Quote | #4

    我用squid 3.0 stable8版本的,在squid.conf文件里设置了negative_ttl 1 second
    发现还是一样缓存了404的网页,请问直接能404 403 302这种类型加过期的http头怎么实现呢?

  5. gzmaster
    Nov 5th, 2008 at 13:36
    Reply | Quote | #5

    可以通过以下的办法不缓存404的页面,
    acl broken302 http_status 400-404 302
    http_access deny Broken302

  6. admin
    Nov 5th, 2008 at 14:24
    Reply | Quote | #6

    根据我的测试,程序优先级最好,然后是apache.negative_ttl 设置好象小于60就不会生效 ,你可以测试一下,有结果讲讲.
    在3.0中可以使用http_status,向楼上讲的那样来配.但我没用过squid3.0

  7. 唐非糖
    Jan 22nd, 2010 at 06:59
    Reply | Quote | #7

    老师好,我将该参数设了0,发现也能缓存404,纳闷?
    negative_ttl 0

  8. admin
    Jan 25th, 2010 at 01:37
    Reply | Quote | #8

    这个,我出在不测试了,什么原因我也不能回答你,不过,我知道squid3.0可以直接拿http头来做acl,你可以玩玩,只是3.0性能实在是不行