I want to be able to apply caching to Static files on my site.
I want the caching to apply to specific file extensions only but I'm not 100% certain of the syntax to add to my web.config
file.
This is what I have so far:
<staticContent>
<remove fileExtension=".svg" />
<remove fileExtension=".jpg" />
<remove fileExtension=".png" />
<remove fileExtension=".gif" />
<remove fileExtension=".css" />
<remove fileExtension=".js" />
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml"/>
<mimeMap fileExtension=".jpg" mimeType="image/jpg"/>
<mimeMap fileExtension=".png" mimeType="image/png"/>
<mimeMap fileExtension=".gif" mimeType="image/gif"/>
<mimeMap fileExtension=".css" mimeType="text/css"/>
<mimeMap fileExtension=".js" mimeType="text/javascript"/>
</staticContent>
Am I right in thinking this will apply 1 day cache to the static files with the following extensions?
- .svg
- .jpg
- .png
- .gif
- .css
- .js
It looks like the clientCache
node in the config doesn't directly tie to the mimeMap
statements. I don't necessarily want the clientCache
to work for files outside of the specified list.
Also, are there any 'gotchas' to this method I should be wary of?
Thanks for any help.
Site details:
- ASP.NET MVC 3
- IIS7