如何让firefox缓存我的图像?

时间:2011-06-27 05:33:44

标签: iis iis-7

我尝试过设置:

<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />

Firefox似乎仍然没有在我的Web.config文件中缓存我的图像。我发现了以下建议。有谁知道这有用吗?有人使用这样的东西吗?

<location path="MyWebsite"> 
    <system.webServer> 
        <caching> 
            <profiles> 
                <add extension=".html" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" /> 
                <add extension=".htm" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" /> 
                <add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" /> 
                <add extension=".js" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" /> 
                <add extension=".css" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" /> 
                <add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" /> 
                <add extension=".jpeg" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" /> 
            </profiles> 
        </caching> 
    </system.webServer> 
</location>

1 个答案:

答案 0 :(得分:1)

FireFox忽略了IIS配置的内容。

它添加了Cache-Control标头max-age 例如:缓存控制:max-age = x

我不得不改变我的web.config以使用cacheControlMode =“UseExpires”。

  <system.webServer>
    <staticContent>
      <clientCache cacheControlCustom="public" cacheControlMode="UseExpires" httpExpires="Sun, 31 Dec 2034 00:00:00 GMT"/>
    </staticContent>
  </system.webServer>

此配置添加了Cache-Control和Expires标头。这似乎告诉FireFox缓存文件。 例如: 缓存控制:公共 到期日:太阳报,2034年12月31日00:00:00 GMT