Wednesday, March 6, 2013

AJAX Caching issue in Internet Explorer (IE) 9 (way back upto IE 6)

I had been pulling my hair apart for resolving the browser compatibility issue. My MVC App has been working well in other browsers, but while doing testing, I found a notorious issue in IE. I had been hung on this issue for several hours. Tried clearing history/cache.. No luck. Tried using the cache trough developer tools (F12)... No luck.. Tried resetting the Browser to its default installation, thinking I might have accidently clicked on a setting for the browser to malfunction... No luck! restarted the machine a couple of times.... But I guess I was looking at the wrong place. Doing a google search for the correct keywords might have helped in the first place! Further research led me to find that IE caches the AJAX requests while others don't. Thats actually BAD news for me, because that gives me inconsistency in data.


Fellow internet geeks had posted a few solutions to overcome this issue:

http://dougwilsonsa.wordpress.com/2011/04/29/disabling-ie9-ajax-response-caching-asp-net-mvc-3-jquery/

http://www.dashbay.com/2011/05/internet-explorer-caches-ajax/

http://ivida.co.uk/2011/09/29/ie-9-ajax-request-caching-mvc/




This worked for me! Yay!

$(document).ready(function() {
$.ajaxSetup({ cache: false });
});

No comments:

There was an error in this gadget