Flying rabbit Download | Flying rabbit site management
homeRelevant informationThe configuration method of prohibiting caching a single static file in IIS7 and iis7.5
The configuration method of prohibiting caching a single static file in IIS7 and iis7.5

In IIS7, you want to set a frequently modified static file as non cacheable.

1、 Method for prohibiting caching of single file

just stumbled across this question; You can use the following to disable the cache on a specific file: if you see this problem occasionally, you can disable the caching of a single file through the following methods

<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) note that the writing method of the path needs to be alternative to the path of the web.config file, 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; Or put this file in a separate directory and disable caching through its own web. Config file.

2、 By setting files in a directory, files in this directory will not be cached

<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] the iis7.5 cache in win7 has also been tested, but you need to confirm whether it can run normally in azure.