It seems that all the browsers other than Opera cache XHR requests in my Javascript program. The URL in the XHR request refers to a CGI program on the server which generates a different output everytime its called. B Is there a way in Javascript to make the browser not cache XHR requests?
-
Here you go! (This link helps you disable caching using
xmlHttpReq).Or, you can use jQuery's Ajax feature, and disable caching by setting it's
cachetofalse. Might be a cleaner option.Girish : thanks, it works now!From Chetan -
every ajax request you make, generate a unique value and add it to the ajax url as a query:
/example/url/post.php?rand=09809807896768I tend to generate the cuurent unix timestamp in js and use that - ensures I do not get replicated unique stamps.
that way every request is unique and will not get cached. This is a simple but fairly common ajax trick - usually fixing IE and testing issues.
If you were to use jquery - it does this for you.
Girish : Thanks. I tried adding new Date().getTime() that worked too.From Glycerine
0 comments:
Post a Comment