IIS7、iis7.5中禁止緩存單個靜態(tài)文件的配置方法
IIS7中,想將一個經常修改的靜態(tài)文件設置為不可緩存,在IIS配置界面里怎么也找不到...
一番google之后在stackoverflow里邊發(fā)現了這樣一段回答,最終解決了問題:
一、單個文件的禁止緩存的方法
just stumbled across this question; you can use the following to disable the cache on a specific file:
偶爾看到這個問題,你可以通過下面的方法來對單個文件進行禁止緩存
<configuration>
<location path="path/to/the/file">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>
</location>
</configuration>
(Note that the path is relative to the web.config file)
注意路徑的寫法需要相對于web.config文件的路徑
Alternatively, place the single file in a directory on it's own, and give that directory it's own web.config that disables caching for everything in it;
或者是將這個文件放一個單獨的目錄里面,然后通過它自己的web.config文件來禁用緩存。
二、通過將文件放到一個目錄里面進行設置,這個目錄里的文件都不會緩存
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="no-cache" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
[Both tested on IIS7.5 on Windows 7, but you'll have to confirm that it works OK on Azure]
在win7中的iis7.5緩存也測試過,不過你需要確認他在Azure能否正常運行。
相關文章
windows server 2008 R2 禁用ipv6和隧道適配器
這篇文章主要介紹了windows server 2008 R2 禁用ipv6和隧道適配器,需要的朋友可以參考下2015-09-09
win2003服務器/虛擬主機不支持Flv和ANI格式文件的解決方案
關于2003服務器/虛擬主機不支持Flv和ANI格式文件的解決方案解決2003不支持FLV的方法2011-05-05
Windows Server 2012顯示或隱藏桌面上的通用圖標教程圖解
Windows Server 2012與Windows Server 2008 在顯示或隱藏桌面上的通用圖標是不同的。這篇文章通過圖文并茂的形式給大家介紹Windows Server 2012顯示或隱藏桌面上的通用圖標,感興趣的朋友一起看看吧2018-12-12
Windows Server 2019 取消默認IE 瀏覽器安全增強配置的步驟
Windows Server 2019 操作系統打開ie瀏覽器的時候各種對話框提示,下面就為大家分享一下解決方法2022-08-08

