I’m not sure what I’m doing wrong but despite of everything I’ve tried, I don’t seem to be able to get the clients to cache my static resources.
In my web.config, I’ve added the following entry:
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
</staticContent>
According to the documentation, this should send a response header to the client browser to let it know we want to keep static content cached for 30 days.
If I use fiddler to see what the client is receiving, it looks like my web.config addition gets ignored completely.
Below is what fiddler is reporting:
Cache-Control: no-cache
Date: Mon, 05 Dec 2011 14:09:44 GMT
Expires: -1
Pragma: no-cache
Vary: Accept-Encoding
I don’t have any headers in IIS overriding this so I’m not sure what is it that I am missing. Any help would be greatly appreciated.
I cracked this but it took a while. You’re trying to force 304s from the server (no change). It differs with IIS versions.
It’s best achieved by having all you’re static content in one directory
(e.g.
contentso you’d have/content/css/content/js etc)Then you just have to ensure everything under that directory doesn’t expire for, say, 30 days.
IIS7
Much easier. Easiest way – add a
web.configto the content directory referred to above. Thisweb.configwill have just the expires directive:IIS6
You’ll need to manipulate the metabase. It’s not XML in IIS6, follow the instructions here: IIS6 ETags metabase commands
We used both the above and simple viewing of firebug shows 304s coming through.