c# - 使用 Web.config 禁用单个 JS 文件的缓存

标签 c# asp.net caching

我目前在我的网站上缓存所有可能的内容(图像、JS、CSS)。我每次只需要重新加载一个 JS 文件。如何使用 web.config 只从缓存中省略一个文件,同时保留所有其他文件缓存?

请注意,我在这里尝试了另一个链接,它似乎并没有停止缓存我的文件: How do I disable caching of an individual file in IIS 7 using weserver config settings

最佳答案

怎么样:

<configuration>
  <location path="path/to/the/file.js">
    <system.webServer>
      <staticContent>
        <clientCache cacheControlMode="DisableCache" />
      </staticContent>
    </system.webServer>
  </location>
</configuration>

(注意路径是相对于web.config文件的)

关于c# - 使用 Web.config 禁用单个 JS 文件的缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5235309/

相关文章:

spring - net.sf.ehcache 和 org.ehcache 之间的区别?

ubuntu - 在 github actions ubuntu-latest 上收到 "Cache not found for input keys: cache-playwright-linux-1.20.0"

c# - 是否可以缓存在 lambda 表达式中计算的值?

c# - 在 WPF 中隐式禁用动画

c# - 一种优雅的方式来做到这一点?可能是泛型?

jquery - WCF:使用 JSONP 将来源列入白名单

caching - CSS 背景图片间歇性地出现在谷歌浏览器中

c# - 模拟多态/泛型枚举 - C#

asp.net - 在 ASP.NET 中从数据库自动生成 ID

c# - 无法在用户管理器中访问 CreateAsync