Which browsers have problems caching XMLHTTPRequest responses?

前端 未结 2 1953
生来不讨喜
生来不讨喜 2020-12-15 13:28

Do any of the currently popular browsers have particular problems caching* XMLHttpRequest responses that I need to be aware of?

I\'d like to be able to include XMLHt

相关标签:
2条回答
  • 2020-12-15 13:46

    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.

    0 讨论(0)
  • 2020-12-15 13:48

    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.

    0 讨论(0)
提交回复
热议问题