Which browsers have problems caching XMLHTTPRequest responses? Which browsers have problems caching XMLHTTPRequest responses? ajax ajax

Which browsers have problems caching XMLHTTPRequest responses?


Mark Nottingham has an excellent set of functional tests that demonstrate browser XMLHttpRequest caching behaviour. Load up the page in the browsers you want to support and work out what techniques you can and cannot rely on to have your response cached.


Although some browsers have different defaults (by default, IE will cache results from AJAX requests, but Firefox, by default, will not), all browsers that I'm aware of will obey the http headers, such as Cache-Control. So just set the caching headers correctly for your application.

Here is an example:

    public ActionResult SomeAction()    {        var model = [...];        Response.AddHeader("Cache-Control", "no-cache");        return Json(model);    }

Now IE and Firefox will both behave the same; they will never cache the results of the action.