zoukankan      html  css  js  c++  java
  • 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

    了,证明配置生效~

  • 相关阅读:
    java实现万年历
    XCTF 逆向 re1-100
    iOS多线程开发之GCD
    Hexo Next统计文章访问量
    Name/Value 配對和物件
    Mac系统Git生成ssh公钥
    《大话数据结构》三
    C++指针和引用
    英语语法讲解第一课句子成分-表语
    String-mainipulation7
  • 原文地址:https://www.cnblogs.com/tzyy/p/4898487.html
Copyright © 2011-2022 走看看