Strange XMLHttpRequest bug in IE
I’ve been dumbfounded with a javascript issue under IE which doesn’t manifest itself under FireFox. Here’s the premise - I have a page which has a single XMLHttpRequest object making calls to the server for additional information in the background. The XMLHttpRequest object requests a URL from a queue of URLs and then the callback function handles the returned content. Once the content is returned properly and I know the XMLHttpRequest is finished, I perform a new request for the next URL in the queue until there are no more URLs to work with. Under FireFox, this works beautifully. Data is loaded in the background and the user sees a page which updates smoothly as cells begin to fill in over time.
Under IE, the first load of the page doesn’t cause a problem. However, once I reload or refresh the webpage, I come across a Stack Overflow Issue. At first, I thought this was a problem with the XMLHttpRequest object but everything in my code was correct. I was calling open() before setting the callback function under IE which meant that I could reuse the object again and again. I was also not showing any visible leaks under Drip. After hours of searching, I came across this interesting comment in wikipedia about IE caching of GET requests. I already figured that IE was caching my GET requests and would probably load these cached pages if I were to refresh the main page. However, I didn’t think this would cause the problem I was witnessing. But hey.. I was out of solutions, so I decided to implement the code that gets around the GET request caching of IE. Refreshed the page.. and guess what ? No more Stack Overflows. What the??? It’s been working beautifully since. I don’t really understand why I would get a stack overflow if IE is trying to load the page from it’s cache.. unless it can’t actually find the page which is also doubtful. Whatever the issue.. my problems appear to have disappeared. Here’s the pointer to the page where I found the solution:
http://en.wikipedia.org/wiki/Xmlhttprequest#Microsoft_Internet_Explorer_cache_issues
In particular, I set the setRequestHeader method of the XMLHttpRequest object to:
req.setRequestHeader( “If-Modified-Since”, “Sat, 1 Jan 2000 00:00:00 GMT” );


