2013-06-06 21 views
0

我有一個nginx web服務器設置,我需要爲我的索引頁指定單獨的瀏覽器級緩存失效(失效)。Nginx爲索引頁設置單獨的瀏覽器緩存失效

我試圖

location =/{ 
expires 1m; 
root /data/site; 
index index.htm; 
} 


location /{ 
expires 5d; 
root /data/site; 
} 

index.htm網頁應該有1米但即時得到5D的響應頭到期。

回答

0

終於有了答案。 必須手動完成nginx工作。

處理請求「/」更復雜。它僅由前綴位置「/」匹配,因此它由此位置處理。然後,index指令根據其參數和「root/data/site」指令測試是否存在索引文件。如果文件/data/site/index.htm存在,則該指令執行內部重定向到「/index.htm」,並且nginx再次搜索位置,就好像該請求已被客戶端發送 ..

所以我不得不增加一個位置來搜索我的index.htm文件

location ~* \index.(htm?l)$ { 
    expires 1d; 

    root /data/site; 
    index index.html index.htm; 
}