Our site's favicon.ico file hasn't changed in years - and isn't going to change any time soon - so I'd like to configure IIS to serve it with a far-future cache expiry header. The rest of the content in the root folder of my site is dynamic pages that shouldn't be cached - but as far as I can tell, IIS only allows you to set content expiry cache on a per-folder basis - so is there any way to set a cache header for favicon.ico without affecting the rest of the content in the home directory as well?
Yep - drill down to the file.
In IIS Manager (on IIS6), navigate to the file, right click, properties, HTTP Headers tab, check Enable Content Expiration; party on with the other settings.
Kudos to Dylan (below) for IIS7 instructions and this snippet.
This creates the following section in web.config, so you can probably achieve the same thing just by editing the file directly.
<configuration>
<location path="favicon.ico">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="90.00:00:00" />
</staticContent>
</system.webServer>
</location>
</configuration>
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