IIS7: Cache Setting Not Working… why?

亡梦爱人 提交于 2019-12-02 04:38:25

问题


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:


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> 


来源:https://stackoverflow.com/questions/6165218/iis7-cache-setting-not-working-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!