Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1057753
  • 博文数量: 321
  • 博客积分: 7872
  • 博客等级: 少将
  • 技术积分: 2120
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-16 09:06
文章分类

全部博文(321)

文章存档

2017年(1)

2016年(1)

2015年(12)

2014年(17)

2013年(78)

2012年(15)

2011年(17)

2010年(67)

2009年(102)

2008年(11)

分类: LINUX

2010-04-30 10:17:30

refresh_pattern
------------------------------------------------------------
只对后端没设置Expires过期时间的页面起作用,比如论坛页面;
而对类似apache mod_expires 设置过的页面不起作用。
------------------------------------------------------------

说明之前,先将个概念LM,LM就是页面Header里时间(Date)和Last-Modified时间的差。Date一般是Squid从后面取页面的时间,Last-Modified 一般是页面生成时间。

refresh_pattern 的语法是
refresh_pattern [-i] regexp min percent max [options]


regexp 就不讲了,大家都明白的;)
min, max的单位是分钟,percent就是百分比。

refresh_pattern 的算法如下:(当前时间定义为CURRENT_DATE)
1) If ((CURRENT_DATE-DATE(就是LM里定义的时间)) < min),cache是新鲜的
2) else if ((CURRENT_DATE-DATE) < (min + (max-min)*percent),cache是新鲜的
3) else cache是过期的
cache过期就需要从后面server取新鲜内容。

如果希望页面一进入cache就不删除,直到被主动purge掉为止,可以加上ignore-reload选项
一般情况可以使用 reload-into-ims。

举例:
refresh_pattern -i \.gif$   1440    50%     2880      ignore-reload
refresh_pattern -i \.jpg$   1440    50%     2880      ignore-reload
refresh_pattern -i \.png$   1440    50%     2880      ignore-reload

refresh_pattern -i \.mp3$   1440    50%     2880      ignore-reload
refresh_pattern -i \.wmv$   1440    50%     2880      ignore-reload
refresh_pattern -i \.rm$   1440    50%     2880      ignore-reload
refresh_pattern -i \.swf$   1440    50%     2880      ignore-reload
refresh_pattern -i \.mpeg$   1440    50%     2880      ignore-reload
refresh_pattern -i \.wma$   1440    50%     2880      ignore-reload

refresh_pattern -i \.css$ 10 50% 60 reload-into-ims
refresh_pattern -i \.js$ 10 50% 60 reload-into-ims
refresh_pattern -i \.xml$ 10 50% 30 reload-into-ims
阅读(952) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~