Which browsers have problems caching XMLHTTPRequest responses?

前端 未结 2 1955
生来不讨喜
生来不讨喜 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.

提交回复
热议问题