How to actually set max-age headers on Windows Server?

by FlavorScape   Last Updated January 14, 2018 12:00 PM

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" />


Answers 2


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.

FlavorScape
FlavorScape
July 09, 2013 20:26 PM

Just so we are clear how it should be

<staticContent>
       <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="0.00:01:00" />
</staticContent>
Valentin Kuzub
Valentin Kuzub
January 14, 2018 11:41 AM

Related Questions


Disable IIS Output cache, for good

Updated April 05, 2017 10:00 AM