How can I urn off browser caching for all aspx pages?

K

Ken Varn

Is there anyway within my web application that I can have all browser
caching turned off for all aspx pages sent by my IIS server? I need to have
all caching off in order for certain things to work properly, and I can't
always rely on the user disabling their cache settings at the browser level.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
 
J

Juan T. Llibre

Unfortunately, using :
<META HTTP-EQUIV="pragma" Content="nocache">
doesn't work too good in some browsers.

The correct object to use is :

SetCacheability(HttpCacheability.NoCache)
 
J

Jeppe Jespersen

The correct object to use is :

SetCacheability(HttpCacheability.NoCache)

Agreed.

Perhaps even accompanied by:
SetAllowResponseInBrowserHistory(false)

Jeppe Jespersen
Denmark
 
B

Bruce Barker

note: these are all hints to the browser (and proxy servers) and may be
ignored.

-- bruce (sqlwork.com)
 
J

Juan T. Llibre

Hmm...

SetAllowResponseInBrowserHistory(false) is the default.

You only need to set
HttpCachePolicy.SetAllowResponseInBrowserHistory
when you need to set it to true ( to override the NoCache setting ).
 
K

Ken Varn

Thanks for all of the information on this post. I take it that there is no
global way to turn caching off for the entire ASP.NET application? It would
be nice if there was something in web.config where I could turn off caching
for the whole application.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
 
J

Juan T. Llibre

I really hesitated before writing this, since tinkering
with basic functionality could have unexpected results.

You could try disabling the entire OutputCache module.

The OutputCache is a module which is added to ASP.NET's
core via a line in machine.config's httpmodules section :


<httpModules>
<add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />

You could *experiment* removing that line.
You might have to make other adjustments, too.

Disclaimer: if you do this, you do it on your own behalf.
I do not accept any responsibility for unexpected results.

Good luck, if you decide to experiment with this.






Ken Varn said:
Thanks for all of the information on this post. I take it that there is no
global way to turn caching off for the entire ASP.NET application? It would
be nice if there was something in web.config where I could turn off caching
for the whole application.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
 
K

Ken Varn

I tried another approach that seems to work, but please verify.

I modified the global.asax.cs file an added the
SetCacheability(HttpCacheability.NoCache) call in the
Application_BeginRequest event.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
Juan T. Llibre said:
I really hesitated before writing this, since tinkering
with basic functionality could have unexpected results.

You could try disabling the entire OutputCache module.

The OutputCache is a module which is added to ASP.NET's
core via a line in machine.config's httpmodules section :


<httpModules>
<add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />

You could *experiment* removing that line.
You might have to make other adjustments, too.

Disclaimer: if you do this, you do it on your own behalf.
I do not accept any responsibility for unexpected results.

Good luck, if you decide to experiment with this.






"Ken Varn" <nospam> wrote in message news:[email protected]...
 
J

Juan T. Llibre

Great idea!

That will, in effect, act as a global directive since the
Application_BeginRequest event is called in all requests.

Congratulations on your smart move!
 
J

Joerg Jooss

Yunus said:
Use pragma no-cache

That's almost useless. Use true HTTP 1.1 features to prevent caching
(not that browsers need to honor them anyway).

Cheers,
 
J

Joerg Jooss

Bruce said:
note: these are all hints to the browser (and proxy servers) and may
be ignored.

True for browsers (unfortunately), but proxies? The HTTP 1.1 spec has
MUST NOT written all over sections 14.9.1 and 14.9.2 ;-)


Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top