Iis – How to actually set max-age headers on Windows Server

cacheiisttlweb.config

I've set the max age to 1 minute, but when I look at the response headers, I see max-age=86400 (one day). Is something else overriding this setting? I've also set the kernel cache to 1 minute for most mime types to make sure that's not the source. Is there anywhere else I should look for an override? Another webconfig setting?

Here's the relevant part of the webconfig.

<system.webServer>
      <urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true" />      
      <caching enabled="true">
        <profiles>              
          <add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
          <add extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
          <add extension=".js" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
          <add extension=".css" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
          <add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
          <add extension=".jpeg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
        </profiles>
      </caching>
    <staticContent>
        <!--Enable gzipping JS by changing the mime type.-->
        <remove fileExtension=".js" />
        <mimeMap fileExtension=".js" mimeType="text/javascript" />
        <!-- d.hh:mm:ss -->
        <clientCache cacheControlMode="UseMaxAge" httpExpires="0.00:01:00" />

Best Answer

Should Use

cacheControlMaxAge="0.00:01:00" 

instead of

httpExpires="0.00:01:00"

but the latter does not throw an error, just doesn't work.

Related Topic