IIS7、iis7.5中禁止緩存單個靜態(tài)文件的配置方法
IIS7中,想將一個經(jīng)常修改的靜態(tài)文件設(shè)置為不可緩存,在IIS配置界面里怎么也找不到...
一番google之后在stackoverflow里邊發(fā)現(xiàn)了這樣一段回答,最終解決了問題:
一、單個文件的禁止緩存的方法
just stumbled across this question; you can use the following to disable the cache on a specific file:
偶爾看到這個問題,你可以通過下面的方法來對單個文件進(jìn)行禁止緩存
<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;
或者是將這個文件放一個單獨(dú)的目錄里面,然后通過它自己的web.config文件來禁用緩存。
二、通過將文件放到一個目錄里面進(jìn)行設(shè)置,這個目錄里的文件都不會緩存
<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緩存也測試過,不過你需要確認(rèn)他在Azure能否正常運(yùn)行。
相關(guān)文章
遠(yuǎn)程桌面連接時提示終端服務(wù)器超出了最大允許連接數(shù)解決方法小結(jié)
這幾天頻繁的遠(yuǎn)程登陸服務(wù)器,由于沒有及時注銷或者其他情況,早上再次登陸時系統(tǒng)提示:終端服務(wù)器超出了最大允許連接數(shù)。2010-09-09
Windows Server 2019 WEB和FTP服務(wù)器的配置方法
這篇文章主要介紹了Windows Server 2019 WEB和FTP服務(wù)器的配置方法,這都是基本的,需要的朋友可以參考下2022-08-08
win2003 sp2 安裝iis提示無法復(fù)制文件解決辦法[已測]
Windows2003打了SP2補(bǔ)丁再安裝IIS提示無法復(fù)制文件,或安裝了sp2的系統(tǒng),卸載iis再安裝也會提示無法復(fù)制文件,或找不到文件。2011-12-12
VMware虛擬機(jī)安裝?Windows?Server?2022的詳細(xì)圖文教程
這篇文章主要介紹了VMware虛擬機(jī)安裝?Windows?Server?2022的詳細(xì)圖文教程,需要的朋友可以參考下2022-09-09
IIS PHP環(huán)境Temp文件夾的權(quán)限問題引起的網(wǎng)站故障
服務(wù)器非常慢,把WINDOWS2003重啟了,結(jié)果連不上服務(wù)器。結(jié)果悲劇的去了機(jī)房2013-02-02
win服務(wù)器防止安全策略或防火墻配置錯誤而導(dǎo)致遠(yuǎn)程無法連接的bat
這篇文章主要介紹了win服務(wù)器防止安全策略或防火墻配置錯誤而導(dǎo)致遠(yuǎn)程無法連接的bat,需要的朋友可以參考下2017-04-04
windows7服務(wù)器上weblogic啟動失敗異常解決方法
windows7服務(wù)器上weblogic啟動失敗異常:/Java/jre6/lib/ext/QTJava.zip was unexpected at this time,接下來介紹詳細(xì)解決方法,需要的朋友可以參考下2013-01-01

