Reputation: 21585
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?
Upvotes: 7
Views: 6383
Reputation: 21585
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.
Upvotes: 5
Reputation: 6893
I've found Google PageSpeed in some instances takes a bit of time to 'catch up' with recent changes you've made. Make sure you've done a full page refresh and hit the refresh button in PageSpeed itself. Failing that, using Firebug on Firefox always seems to give accurate results in the net tab. Click the plus icon next to the file and examine the response headers.
Upvotes: 0