【问题标题】:Differences between caching components in web config [duplicate]Web 配置中缓存组件之间的差异 [重复]
【发布时间】:2011-09-28 11:05:51
【问题描述】:

web config 中这两个缓存组件有什么区别?

<staticContent>
    <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="90.00:00:00" />        
</staticContent>

<caching>
    <profiles>
        <add extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
        <add extension=".jpeg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
        <add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
        <add extension=".css" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
        <add extension=".js" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
    </profiles>
</caching>

我很难找到关于第二个版本的信息。当它说“CacheUntilChange”时,什么构成了更改,为什么会有持续时间?

谢谢

【问题讨论】:

  • 我想知道同样的事情,在某些时候我想我明白了。持续时间用于重新检查文件是否仍然有效以及是否已更改...假设浏览器要求 test.jpg,浏览器被告知缓存它直到更改,但浏览器将如何知道什么时候改的吗?持续时间指定检查的时间......或者我想相信。

标签: iis caching


【解决方案1】:

我也面临着类似的疑问。这是我从互联网上的大量内容中得出的结论。

如果我错了,请随时纠正我或添加更多信息以防我遗漏任何内容。

1) &lt;staticContent&gt;&lt;clientCache> 仅在客户端缓存。

缓存配置文件可用于在客户端和服务器端缓存文件。 在两个集合上配置 location="ServerAndClient"policy标签配置客户端缓存策略,kernelCachePolicy标签配置服务器缓存策略。

2) 静态内容缓存不支持基于文件类型或扩展名的缓存。

缓存配置文件支持基于扩展的缓存。

3) 要将静态内容缓存应用于特定位置的文件,您可以使用主 web.config 中的位置标记,以便静态内容缓存应用于该位置的所有文件。

例如

  <location path="Content/common/images">
    <system.webServer>
      <staticContent>
        <clientCache cacheControlCustom="public" cacheControlMaxAge="86400" cacheControlMode="UseMaxAge"/>
      </staticContent>
    </system.webServer>
  </location>

上述标签将对“Content/common/images”文件夹中的所有文件应用缓存。 或者staticContent标签也可以在需要缓存内容的文件夹中的本地web.config中指定。

对于缓存配置文件,要应用于特定文件夹,您可以在文件夹本地的配置文件中指定缓存配置文件部分。

除了位置特定的配置文件外,还将应用主 web.config 中应用的所有配置文件。

4) 要通过 IIS 配置 StaticContent 缓存,需要使用 HTTP Response Headers 配置窗口

要通过 IIS 配置缓存配置文件,您需要使用 OutputCaching 配置窗口。

【讨论】:

    猜你喜欢
    • 2012-12-02
    • 1970-01-01
    • 1970-01-01
    • 2014-04-05
    • 1970-01-01
    • 2014-11-28
    • 2016-05-04
    • 1970-01-01
    • 2013-06-01
    相关资源
    最近更新 更多