| | Stumble It! | Add to Mixx! | | diigo it | | Slashdot |

Monday, June 14, 2010

Clever Solution to IE Caching Ajax

I ran into a problem today where IE was caching my AJAX responses so updates wouldn't be displayed and after a bit of hand-wringing over some of the suggested solutions (swapping GETs for POSTs, re-writing the page inPHP, etc), I found a clever little solution - add a time stamp to the GET string.
var t = new Date().getTime();
...
ajaxUrl += '&timestamp='+t;
...
Adding this time stamp will differentiate the URL and thereby force IE to reload the Ajax content.

Win.

0 comments: