IIS7: Cache Setting Not Working… why?

2019-02-26 07:35发布

My IIS7 web.config is set to the following with a folder of static assets (not within an ASP.NET app or anything):

<?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>

When I try to access a Silverlight .XAP file, I expect IIS to tell the browser that it can be cached for 500 days.

However, this is the cache header:

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

Why is IIS still adding no-cache to this header with the above configuration file?

1条回答
孤傲高冷的网名
2楼-- · 2019-02-26 08:14

You need to configure IIS to treat XAP as static content. Try this:

<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> 
查看更多
登录 后发表回答