Tuesday, June 16, 2009

Caching Problem with XMLHttpRequest

Using XMLHttpReuest is fun. But if you have just started the fun, you should know this.
IE has a known issue which caches the data if request is same. It's real mystery for me why Microsoft ended up with such default behavior for functionality which is responsible to load dynamic data. But as we have to live with it, here is a small hack which will turn off the caching for that page. You need to add this two lines in your HTML Head tag.

< meta equiv="Pragma" content="no-cache"/>
< meta http-equiv="Expires" content="-1" />

Solution Source: http://en.wikipedia.org/wiki/XMLHttpRequest#Workaround