Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS7 cacheControlMaxAge attribute not working

In IIS 7.5 I have set the cacheControlMaxAge to be one year like so

<location path="Content/Images">
    <system.webServer>
      <staticContent>
        <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
      </staticContent>
    </system.webServer>
  </location>

As per this guide: Setting Expires and Cache-Control: max-age headers for static resources in ASP.NET

However, the Google PageSpeed tool is still saying that the files are not cached:

The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:
* https://local.example.com/Content/Images/image1.png (expiration not specified)
(etc)

Why does it say "expiration not specified"?

The entire webapp is served over https, is that a factor?

like image 460
JK. Avatar asked Sep 29 '12 00:09

JK.


1 Answers

I solved this by changing the path specified from Content/Images to just Content

<location path="Content">
    <system.webServer>
      <staticContent>
        <clientCache cacheControlCustom="public" 
                     cacheControlMode="UseMaxAge" 
                     cacheControlMaxAge="365.00:00:00" />
      </staticContent>
    </system.webServer>
  </location>

So it is fixed, but the changing of the path does not make it clear what the problem actually was.

like image 70
JK. Avatar answered Oct 01 '22 01:10

JK.