2011-04-18 54 views
2

我們希望能夠建立在Apache的基於用戶代理的Cache-Control頭條件申報的httpd

例如,如果一個用戶代理包含子foo我們想要的Cache-Control設置爲10分鐘。但如果沒有設置爲1天。

摸索,我發現BrowserMatch,但似乎只設置環境變量:

BrowserMatch foo short-live # Sets environment variable short-live 

不過,我想有條件地應用指令像Header set ...ExpiresDefault ...

是否有辦法有條件地申請聲明?例如:

<FilesMatch "\.(jpg|jpeg|gif|png|js|css)$"> 
    Header set Cache-control "max-age=86400" 
    <IfBrowser "foo"> 
    Header set Cache-control "max-age=600" 
    </IfBrowser> 
</FilesMatch> 

注意,IfBrowser是虛構的。有沒有真正的指令可以像這樣使用?謝謝!

+0

轉貼到http://serverfault.com/questions/261346/contional-declaration-in-apache-httpd因爲缺乏在這裏迴應。 – sligocki 2011-04-19 16:45:06

回答

2

啊哈,這要歸功於@muffinista在ServerFault誰找到了解決辦法:

Header set Cache-control "max-age=86400" 
BrowserMatch foo short-cache 
Header set Cache-control "max-age=600" env=short-cache