Caching in ASP.NET - IE cache settings

K

kaczmar2

I have a page written in ASP.NET that uses some Javascript to modidy
the .innerHTML property of a DIV tag. The page works great in FireFox,
but in IE6, the page tends to pull the content out of its local cache
and not modify the DIV tag. The Javascript code is run in the correct
places and during the correct events, it's just that the content of the
page is not being updated. The page uses Postbacks.

My current IE settings specify to "Check for new version of pages:
automatically". If I set this to "Every time", the page works just
fine.

I have included, in my Page_Load, the directive:

Page.Response.Cache.SetCacheability(HttpCacheability.NoCache)

But this does not work. I have also tried:

Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")

but to no avail.

Can anyone help here? I want this page to be reloaded fresh every
time, without having to change the local IE cache settings.
 
G

Guest

/// <summary>
/// This function prevent the page being retrieved from broswer cache
/// </summary>
private void ExpirePageCache()
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now-new TimeSpan(1,0,0));
Response.Cache.SetLastModified(DateTime.Now);
Response.Cache.SetAllowResponseInBrowserHistory(false);
}


Adding a call to this function in Page_Load, should stop this page from
being cached
 
K

kaczmar2

Thanks for the feedback, but I am still having the caching problem.
One thing to note is that I am using the XMLHTTP object in Javascript
to only post back part of a page - like Google suggest does. Could
this be the issue? Although, the page works correctly if I tell IE to
always check for a new version of the page, and FireFox works too.
 
D

Damien

Thanks for the feedback, but I am still having the caching problem.
One thing to note is that I am using the XMLHTTP object in Javascript
to only post back part of a page - like Google suggest does. Could
this be the issue? Although, the page works correctly if I tell IE to
always check for a new version of the page, and FireFox works too.

So, if I read this right, you're using javascript/XMLHTTP to retrieve
more content, and it's this part (rather than your whole page) that is
being served from cache? If so, can you append a pointless parameter to
the URL you're sending (and either keep track and increment this
pointless parameter, or generate them randomly?

Damien
 
K

kaczmar2

Thanks for the tip, it worked. Duh, I should have thought of that
since I am appending a unique value to a query string in another .NET
app I wrote.

I just appended the hours, mnutes, seconds and milliseconds via
JavaScript to my URL and ir worked just fine.
 
D

Damien

Thanks for the tip, it worked. Duh, I should have thought of that
since I am appending a unique value to a query string in another .NET
app I wrote.

I just appended the hours, mnutes, seconds and milliseconds via
JavaScript to my URL and ir worked just fine.
Glad to have helped

Damien
 

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

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top