打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Squid的refresh

 refresh_pattern 大概是 squid 最有意思但最不好懂的配置参数了。

记住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                 
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
对squid中refresh_pattern的一些理解和建议
squid反向代理作web加速-refresh_pattern 配置
squid中的X
squid配置
使用squid加快内网网页浏览速度
lighttpd 负载均衡-反向代理+cache浅谈
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服