...

View Full Version : stop ajax caching?



angst
10-30-2006, 06:09 PM
hello,
I'm not sure if this is the right forum to post this in.

but I'm wondering how i can stop ajax from cashing results,, atleast while testing, i'm finding that i often need to close the browser and re-open it to get an updated result, or if there was an error, I will continue to get the same error even if it was fixed untill i start a new browser session.

thanks in advance for your time!
-Ken

homerUK
10-30-2006, 07:05 PM
I've not experienced caching with ajax - what method are you using to submit/retrieve the data?

angst
10-30-2006, 07:07 PM
I'm using this:

function GetXmlHttpObject(){
var objXMLHttp=null
if (window.XMLHttpRequest){
objXMLHttp=new XMLHttpRequest()
}else if (window.ActiveXObject) {
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}

but I've just solved it by using this ( in .asp )

<% Response.CacheControl = "no-cache" %>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %>

thanks!
-Ken

homerUK
10-30-2006, 07:10 PM
aah cool - glad it's sorted!! ;)

A1ien51
10-30-2006, 09:43 PM
You can do this too:

xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");

Eric



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum