2

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
  • 1
    A better question might be... "Why doesn't IIS think the file it has is newer?" If you could fix that then you won't need to take the performance hit by turning off caching. Commented Jun 7, 2010 at 19:26

1 Answer 1

5

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" />
Sign up to request clarification or add additional context in comments.

5 Comments

But I am trying to accomplish this in web.config, not in code. Is there a better option than <clientCache cacheControlMode="DisableCache" /> ?
Try this (untested!): <clientCache cacheControlCustom="no-store" />
This page iis.net/ConfigReference/system.webServer/staticContent/… does not list "no-store" as a possible setting
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.
@PK, oops! I didn't read your earlier comment carefully enough to see that you used a different attribute (cacheControlCustom instead of cacheControlMode)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.