I'm having an issue with a page in internet explorer. I have an ajax call that calls a form, in other browser, when I click the link it passes in the controller and load correctly data. but in IE, when its loaded once, it aways brings me the same old results without passing in the controller.
+1
A:
You could try setting the cache
option to false
:
$.ajax({
url: '/controller/action',
type: 'GET',
cache: false,
success: function(result) {
}
});
This option will force the browser not to cache the request.
UPDATE:
Based on the comment you could add a unique timestamp to the url to avoid caching issues:
var d = new Date();
var myURL = 'http://myserver/controller/action?d=' +
d.getDate() +
d.getHours() +
d.getMinutes() +
d.getMilliseconds();
Darin Dimitrov
2010-04-16 13:04:22
Well, I'm using Microsoft Ajax, not jQuery. ;) This setting works for all ajax based calls? even for msAjax?
Diego Correa
2010-04-16 13:21:30
oops, sorry, I've missed this important part of your question.
Darin Dimitrov
2010-04-16 13:22:27
A:
Try:
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
This attribute, placed in controller class, disables caching. Since I don't need caching in my application, I placed it in my BaseController class:
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
public abstract class BaseController : Controller
{
Here is nice description about OutputCacheAttribute: Improving Performance with Output Caching
You can place it on action too.
LukLed
2010-04-16 13:59:59
This should not be the issue because the caching only happens in IE
Malcolm Frexner
2010-04-16 14:49:12
@Malcolm Frexner: Caching strategy differs in browsers. There are some problems with IE.
LukLed
2010-04-16 15:03:36
+1
A:
I've blogged about fixing the IE cache issue for both jQuery and the MS client library:
http://yoavniran.wordpress.com/2010/04/27/ie-caching-ajax-results-how-to-fix/
Hope this helps!
poeticGeek
2010-09-29 23:12:57