跳到主要內容

發表文章

目前顯示的是 10月, 2014的文章

Squid refresh-pattern

套用沒有明確定義Expire or Cache-Control:max-age的Req fresh_pattern [-i] regexp min percent max [options] min參數是分鐘數量。它是過時響應的最低時間限制。如果某個響應駐留在cache裡的時間沒有超過這個最低限制,那麼它不會過期。 max參數是存活響應的最高時間限制。如果某個響應駐留在cache裡的時間高於這個最高限制,那麼它必須被刷新。 LM-factor算法 LM-factor=(response age)/(resource age)。 resource age =對象進入cache的時間-對象的last_modified response age =當前時間-對象進入cache的時間 假設源服務器上www.aaa.com/index.htm-----lastmodified 是 2007-04-10 02:00:00 squid上 proxy.aaa.com/index.htm index.htm進入cache的時間 2007-04-10 03:00:00 1)如果當前時間 2007-04-10 03:00:00 resource age =3點-2點=60分鐘 response age =0分鐘 index.htm還可以在cache停留的時間(resource age)*20%=12分鐘 也就是說,index.htm進入cache後,可以停留12分鐘,才被重新確認。 2)如果當前時間 2007-04-10 03:05:00 resource age =3點-2點=60分鐘 response age =5分鐘 index.htm還可以在cache停留的時間(resource age)*20%=12-5=7分鐘 LM-factor=5/60=8.3%<20% 一直到2007-04-10 03:12:00 LM-factor=12/60=20% 之後,cache中的頁面index.htm終於stale。 如果這時沒有index.htm的請求,index.htm會一直在緩存中 如果有index.htm請求,squid收到該請求後,由於已經過期, squid會向源服務器發一個index.htm是否有改變的請求