prevent xmlHttpReq 's browser caching
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 progr开发者_StackOverflowam 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?
For every AJAX request you make, generate a unique value and add it to the ajax URL as a query parameter:
/example/url/post.php?rand=09809807896768
I use to generate the current unix timestamp in JS and use that - this ensures I do not get duplicated 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 by setting the property cache to false on the AJAX settings.
精彩评论