IIS7禁用单个静态文件的缓存配置方法
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) 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; <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]
按照回答中的方法在web.config里边进行配置,再访问,在header里边就可以看到
Cache-Control:no-cache
了,证明配置生效~
分类:
IIS/C#.NET
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?