IIS7:缓存设置不起作用......为什么?

时间:2011-05-29 00:31:28

标签: silverlight iis-7 cache-control browser-cache

我的IIS7 web.config设置为以下静态资源文件夹(不在ASP.NET应用程序或任何内容中):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="500.00:00:00" />
        </staticContent>
        <httpProtocol allowKeepAlive="false" />
    </system.webServer>
</configuration>

当我尝试访问Silverlight .XAP文件时,我希望IIS告诉浏览器它可以缓存500天。

但是,这是缓存标头:

Cache-Control: no-cache,public,max-age=43200000

为什么IIS仍然使用上述配置文件向此标头添加no-cache

1 个答案:

答案 0 :(得分:6)

您需要配置IIS以将XAP视为静态内容。试试这个:

<configuration>
   <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".xaml" mimeType="application/xaml+xml" />
      <mimeMap fileExtension=".xap" mimeType="application/x-silverlight-app" />
      <mimeMap fileExtension=".xbap" mimeType="application/x-ms-xbap" />
    </staticContent>
   </system.webServer>
</configuration> 
相关问题