JoelFan
JoelFan

Reputation: 38734

cache problem in asp.net

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)?

Upvotes: 2

Views: 2043

Answers (1)

Paul Kearney - pk
Paul Kearney - pk

Reputation: 5543

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" />

Upvotes: 5

Related Questions