473,494 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Turn off caching

I need to turn off caching in my ASP.NET page. I have set the following code
in Page Load event:

Response.Cache.SetCacheability(HttpCacheability.No Cache)

Still, sometimes the page is retreived from cache. Are there any other
options I need to set?

TIA
Rohit

Nov 18 '05 #1
13 5665
Rohit,

Which cache are you trying to disable? The caching on the server or the
caching on the client? If you are seeing cached data, it could be server-side
or client-side

Have you checked you settings within IE to see if the page is being cached
client-side?

Also, have you enabled Content Expiration within IIS for the Web you are
testing?

Finally, if you are viewing the pages through the ISA server
(firewall/proxy), then be aware that ISA could be caching the pages for you:
both INbound and OUTbound pages.

Respectfully,

Andrew Corley

"Rohit" wrote:
I need to turn off caching in my ASP.NET page. I have set the following code
in Page Load event:

Response.Cache.SetCacheability(HttpCacheability.No Cache)

Still, sometimes the page is retreived from cache. Are there any other
options I need to set?

TIA
Rohit

Nov 18 '05 #2
Hi Rohit,

I think Andrew's suggestions are reasonable since there could be many
things that can cache the page. In spite of the asp.net serverside or IIS
's cache, if what you want to disable is just the client browser's cache,
you can try set the Response.Expire = -1 so as to make the page expire
immediatly at client side.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3
Hi Rohit,

Any further ideas or questions on this issue? If there is anything else we
can help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4
Yas
Hello,
I have a similar problem. In my case I have a iFrame that I load with several versions of an html file. The html file that I load has a different content every time but is has the same name. The problem that I have is that it shows always the first document that I loaded in the iFrame.
When I select the option: 'enable content expiration/expire inmediately' in IIS everything works ok but I want to get the same behavior from my code. I have tried several things but nothing works.
I would appreciate very much any help to solve this problem,

Thanks,

Yas
PS. here are some of the things that I have tried (in page_load):

Response.Expires = -1;
Response.ExpiresAbsolute = DateTime.Now.AddDays(-2);
Response.CacheControl = "";
Response.AppendHeader("Pragma", "no-cache");

myframe.Page.Response.Expires = -1;
myframe.Page.Response.ExpiresAbsolute = DateTime.Now.AddDays(-2);
myframe.Page.Response.CacheControl = "";
myframe.Page.Response.AppendHeader("Pragma", "no-cache");
From http://www.developmentnow.com/g/8_20...ff-caching.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Nov 19 '05 #5
On Fri, 24 Jun 2005 20:35:16 +0000, Yas wrote:
Hello,
I have a similar problem. In my case I have a iFrame that I load with several versions of an html file. The html file that I load has a different content every time but is has the same name. The problem that I have is that it shows always the first document that I loaded in the iFrame.
When I select the option: 'enable content expiration/expire inmediately' in IIS everything works ok but I want to get the same behavior from my code. I have tried several things but nothing works.
I would appreciate very much any help to solve this problem,

Thanks,

Yas
PS. here are some of the things that I have tried (in page_load):

Response.Expires = -1;
Response.ExpiresAbsolute = DateTime.Now.AddDays(-2);
Response.CacheControl = "";
Response.AppendHeader("Pragma", "no-cache");

myframe.Page.Response.Expires = -1;
myframe.Page.Response.ExpiresAbsolute = DateTime.Now.AddDays(-2);
myframe.Page.Response.CacheControl = "";
myframe.Page.Response.AppendHeader("Pragma", "no-cache");
From http://www.developmentnow.com/g/8_20...ff-caching.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

Try an old trick: add a parameter that changes each time you submit

Nov 19 '05 #6
Try

Response.Cache.SetNoStore();

Stephen

"Yas" <yl******@purdue.edu> wrote in message
news:f1**********************************@msnews.m icrosoft.com...
Hello,
I have a similar problem. In my case I have a iFrame that I load with
several versions of an html file. The html file that I load has a
different content every time but is has the same name. The problem that I
have is that it shows always the first document that I loaded in the
iFrame.
When I select the option: 'enable content expiration/expire
inmediately' in IIS everything works ok but I want to get the same
behavior from my code. I have tried several things but nothing works.
I would appreciate very much any help to solve this problem,

Thanks,

Yas
PS. here are some of the things that I have tried (in page_load):

Response.Expires = -1;
Response.ExpiresAbsolute = DateTime.Now.AddDays(-2);
Response.CacheControl = "";
Response.AppendHeader("Pragma", "no-cache");

myframe.Page.Response.Expires = -1;
myframe.Page.Response.ExpiresAbsolute = DateTime.Now.AddDays(-2);
myframe.Page.Response.CacheControl = "";
myframe.Page.Response.AppendHeader("Pragma", "no-cache");
From
http://www.developmentnow.com/g/8_20...ff-caching.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

Nov 19 '05 #7
Yas wrote:
Hello,
I have a similar problem. In my case I have a iFrame that I load
with several versions of an html file. The html file that I load has
a different content every time but is has the same name. The problem
that I have is that it shows always the first document that I loaded
in the iFrame. When I select the option: 'enable content
expiration/expire inmediately' in IIS everything works ok but I want
to get the same behavior from my code. I have tried several things
but nothing works. I would appreciate very much any help to
solve this problem,

Thanks,

Yas
PS. here are some of the things that I have tried (in page_load):

Response.Expires = -1;
Response.ExpiresAbsolute = DateTime.Now.AddDays(-2);
Response.CacheControl = "";
Response.AppendHeader("Pragma", "no-cache");

myframe.Page.Response.Expires = -1;
myframe.Page.Response.ExpiresAbsolute = DateTime.Now.AddDays(-2);
myframe.Page.Response.CacheControl = "";
myframe.Page.Response.AppendHeader("Pragma", "no-cache");


Uh uh, this looks like a programmer in panic mode ;-)

Now for the usual answer:

There's no guarantee that a browser applies caching or expiration
instructions to locally stored pages. Still, most browsers behave this
way.

Either set the OutputCache directive on your page(s)

<%@ OutputCache Location="None" %>

or set the Cache property of the HttpResponse in your code-behind class:

Response.Cache.SetCacheability(HttpCacheability.No Cache);

Using SetNoStore() as Stephen suggested is even more rigid, but maybe
not the most infrastructure-friendly approach ;-)

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 19 '05 #8
Yas
Hello, thanks for your help but it is still not running the way I want.
I have tried:
Response.Cache.SetNoStore();
Response.Cache.SetCacheability(HttpCacheability.No Cache);

Intrader, you said: "Try an old trick: add a parameter that changes each time you submit". Would you give me please more detail about this trick? Where should I declare that parameter?

In order to make my question more crear I am including the general html structure of my main page:

body MS_POSITIONING="GridLayout"
form id="Form1" name="Form1" method="post" runat="server"
table width="80%" align="center"
tr
td
div id="MyFrameContainer"
SPAN id="ifrmConfigurePage1" runat="server" /SPAN
/div
/td
/tr
tr
td align="center"
INPUT id="Button1" type="button" value="Next" name="Button1" runat="server"
INPUT id="Hidden1" type="hidden" name="Hidden1" runat="server"
/td
/tr
tr
td
div id="MyFrameContainer1"
iframe id="myframe" name="myframe" frameBorder="0" width="100%" height="500%" runat="server"
/iframe
/div
/td
/tr
/table
/form
/body

As you can see I have an Iframe that I load with several versions of an html file. I Load these html files to the Iframe in the code behind.

Any suggestion will be welcome.
Thanks
Yas

From http://www.developmentnow.com/g/8_20...ff-caching.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Nov 19 '05 #9
> Intrader, you said: "Try an old trick: add a parameter that changes each
time you submit". Would you give me please more detail about this trick?
Where should I declare that parameter?

When you specify the url for your html file, do it like this:

'myFile.htm?'+(new Date()).getMilliseconds()

Eliyahu
Nov 19 '05 #10
Yas wrote:
Hello, thanks for your help but it is still not running the way I
want. I have tried:
Response.Cache.SetNoStore();
Response.Cache.SetCacheability(HttpCacheability.No Cache);


So... what happens?

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 19 '05 #11
Yas
The following couple of lines(C#) worked in my case:

DateTime today=DateTime.Now;
myframe.Attributes["src"]=path+"?"+today.Millisecond;

Thank you very much for all your help guys.

Ya

From http://www.developmentnow.com/g/8_20...off-caching.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com
Nov 19 '05 #12
Hi friends,

I am facing almost a similar problem.
But in my case, the html pages are getting cached whereas the asp pages are getting executed afresh. The problem is only with some of the html pages. And these pages are getting cached on the server(iis 5.0). Changing the HTTP header setting is of no effect!

Pls help.

Regards,
Nise
From http://www.developmentnow.com/g/8_20...ff-caching.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Nov 19 '05 #13
Nise wrote:
Hi friends,

I am facing almost a similar problem.
But in my case, the html pages are getting cached whereas the asp
pages are getting executed afresh. The problem is only with some of
the html pages. And these pages are getting cached on the server(iis
5.0). Changing the HTTP header setting is of no effect!


What did you do exactly?

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 19 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1479
by: jawahar Rajan | last post by:
All, I have a default setting of Response.Expires = 1200 is this 20 minutes? or 1200 minutes? The problem I have is say user1 log-in to the web site, and is a valid user, then I display on each...
5
3121
by: R. Ian Lee | last post by:
I have an ASP.NET page that spawns a popup window using javascript's window.open. This works fine. It pops up, you enter some data, press save and everything saves as it should. But, if you...
4
4670
by: Robert Strickland | last post by:
I wish to turn off browser caching through some meta tags. Note the following: <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="-1"> <META...
12
1627
by: Ken Varn | last post by:
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...
3
2463
by: DC | last post by:
Hi, (ASP.Net 1.1) is it possible to (programmatically and globally) deactivate page fragment caching? We have only two scenarios, development stage where we want caching off and testing where we...
0
1189
by: Chris | last post by:
I've been playing with the fragment caching and it seems to work fine. I have a user control that I set to cache. The user control has a few text boxes and a drop down list box populated from a...
1
1013
by: Andrew Clancy | last post by:
Okay my question last night wasnt answered - here's a simpler one: I have a form user control, I want to cache the first page (with clientside validation) but turn caching off whenever anyone...
0
1336
by: Raj | last post by:
What is the purpose of file system caching while creating a tablespace? Memory on the test server gets used up pretty quickly after a user executes a complex query(database is already activated),...
5
7825
by: Raj | last post by:
What is the purpose of file system caching while creating a tablespace? Memory on the test server gets used up pretty quickly after a user executes a complex query(database is already activated),...
0
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5453
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.