IIS7中,想将一个经常修改的静态文件设置为不可缓存。
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能否正常运行。