What browsers have problems caching XMLHTTPRequest responses?

Any of the currently popular browsers have special caching problems * XMLHttpRequest answers that I need to know about?

I would like to be able to include XMLHttpRequest requests on each page as a method of dynamically loading content (e.g. JSON) or behavior (e.g. eval () ed Javascript) per page type, but I want to make sure that the resources it receives from the server can be cached if the server sent the correct headers.

I was interested in reading this article, which mentions that browsers such as Firefox 1.1 do not cache content received through XMLHTTPRequest, and that it always sends new data requests (with Cache-Control and without If-Modified-Since), regardless of the headers sent by the server.

Obviously, the article is very old - I don’t even remember Firefox 1.1; so what kind of considerations do I need to do for popular popular browsers, and are there any tricks when I specifically want the answers to be cached?

** To clarify my question about caching, I mean client-side caching, where the server gives information about freshness (in the form of the Cache-Control: max-age directive or the Expires header :), and the browser stores a copy of the response in the cache along with expiration date, so that future requests for the same resource issued from the following pages can be satisfied from the browser cache without the need for any contact with the server. All major browsers do this correctly for most content, but I heard that Firefox cannot do this for XMLHttpRequest content. I ask if anyone knows of cases where some of the modern browsers do not cache specification responses when using XMLHttpRequest. *

+7
javascript cross-browser ajax caching
source share
2 answers

Mark Nottingham is an excellent set of functional tests that demonstrate the caching behavior of the XMLHttpRequest browser. Load the page in the browsers you want to support, and determine which methods you can and cannot rely on for your response to be cached.

+11
source

Although some browsers have different default values ​​(by default, IE caches AJAX request results, but Firefox will not by default), all browsers that I know about will obey http headers, such as Cache-Control . Therefore, it is enough to correctly configure the caching headers 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 behave the same; they will never cache action results.

+4
source

All Articles