IIS7、iis7.5中禁止缓存单个静态文件的配置方法
IIS7中,想将一个经常修改的静态文件设置为不可缓存,在IIS配置界面里怎么也找不到...
一番google之后在stackoverflow里边发现了这样一段回答,最终解决了问题:
一、单个文件的禁止缓存的方法
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能否正常运行。
相关文章
远程桌面连接时提示终端服务器超出了最大允许连接数解决方法小结
这几天频繁的远程登陆服务器,由于没有及时注销或者其他情况,早上再次登陆时系统提示:终端服务器超出了最大允许连接数。2010-09-09
Windows Server 2019 WEB和FTP服务器的配置方法
这篇文章主要介绍了Windows Server 2019 WEB和FTP服务器的配置方法,这都是基本的,需要的朋友可以参考下2022-08-08
win2003 sp2 安装iis提示无法复制文件解决办法[已测]
Windows2003打了SP2补丁再安装IIS提示无法复制文件,或安装了sp2的系统,卸载iis再安装也会提示无法复制文件,或找不到文件。2011-12-12
VMware虚拟机安装 Windows Server 2022的详细图文教程
这篇文章主要介绍了VMware虚拟机安装 Windows Server 2022的详细图文教程,需要的朋友可以参考下2022-09-09
win服务器防止安全策略或防火墙配置错误而导致远程无法连接的bat
这篇文章主要介绍了win服务器防止安全策略或防火墙配置错误而导致远程无法连接的bat,需要的朋友可以参考下2017-04-04
windows7服务器上weblogic启动失败异常解决方法
windows7服务器上weblogic启动失败异常:/Java/jre6/lib/ext/QTJava.zip was unexpected at this time,接下来介绍详细解决方法,需要的朋友可以参考下2013-01-01


最新评论