views:

31

answers:

1

I'm seeing an issue of some static pages that are using the browser cache, which is not desired. To prevent caching, I'm setting

<clientCache cacheControlMode="DisableCache" />

in the relevant <location> tag in web.config

If I open the page in Firebug (in the Net tab), I see that the Response headers have Cache-Control: no-cache which is correct, but the status of the Response is 304 Not Modified! Isn't that a contradiction? How can I get it to stop caching (i.e. always send a 200 with content)?

+1  A: 

According to the RFC (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.1, section 14.9.1) Cache-control: no-cache tells the browser to not use the cached contents without first revalidating with the server. That's why you're seeing the 304's. I think you're looking for Cache-Control: no-store.

I'm not sure if you can send no-store via a configuration file. You can, however, set the header explicitly in the response:

Response.Cache.SetNoStore();

EDIT: (by OP)

What I was looking for was:

<clientCache cacheControlCustom="no-store" />
Paul Kearney - pk
But I am trying to accomplish this in web.config, not in code. Is there a better option than <clientCache cacheControlMode="DisableCache" /> ?
JoelFan
Try this (untested!): <clientCache cacheControlCustom="no-store" />
Paul Kearney - pk
This page http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache does not list "no-store" as a possible setting
JoelFan
But it does say that it's list is not comprehensive, and gives a reference to RFC 2616 (see my link above). You can use cacheControlCustom to set the cache-control header to any custom value, in this case "no-store", which is valid per the RFC.
Paul Kearney - pk
@PK, oops! I didn't read your earlier comment carefully enough to see that you used a different attribute (cacheControlCustom instead of cacheControlMode)
JoelFan