Search code examples
silverlightiis-7cache-controlbrowser-cache

IIS7: Cache Setting Not Working... why?


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?


Solution

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