Squid的refresh_pattern配置
生活随笔
收集整理的這篇文章主要介紹了
Squid的refresh_pattern配置
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?refresh_pattern 大概是 squid 最有意思但最不好懂的配置參數(shù)了。
記住refresh_pattern 只對后端沒設(shè)置Expires過期時(shí)間的頁面起作用,比如論壇頁面;而對類似apache mod_expires 設(shè)置過的頁面不起作用。
說明之前,先將個(gè)概念LM,LM就是頁面Header里時(shí)間(Date)和Last-Modified時(shí)間的差。Date一般是Squid從后面取頁面的時(shí)間,Last-Modified 一般是頁面生成時(shí)間。
refresh_pattern 的語法是
regexp 就不講了,大家都明白的;)
min, max的單位是分鐘,percent就是百分比。
refresh_pattern 的算法如下:(當(dāng)前時(shí)間定義為CURRENT_DATE)
1) If ((CURRENT_DATE-DATE(就是LM里定義的時(shí)間)) < min),cache是新鮮的
2) else if ((CURRENT_DATE-DATE) < (min + (max-min)*percent),cache是新鮮的
3) else cache是過期的
cache過期就需要從后面server取新鮮內(nèi)容。
如果希望頁面一進(jìn)入cache就不刪除,直到被主動(dòng)purge掉為止,可以加上ignore-reload選項(xiàng)
一般情況可以使用 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
總結(jié)
以上是生活随笔為你收集整理的Squid的refresh_pattern配置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 黄山风景区海拔最高多少米
- 下一篇: Apache URL重定向避免网址结尾斜