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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With