In my first Ajax and REST article, I talked about how the Ajax web programming style and the REST architectural style work well together. While this is true in theory, there are quite a few technical limitations of browsers’ XmlHttpRequest implementations that make it challenging to take advantage of some very basic HTTP capabilities. Case in point, observe this little gem from the MSDN page on the XHR#open method:

Microsoft Internet Explorer caches the results of HTTP GET requests in the Temporary Internet Files (TIF) folder. In most cases, caching improves performance for data that will not change frequently. To guarantee that the results are not cached, use POST.

As Dr. Evil would say, “Riiiiiiiiiight”.

I expect (hope?) that one of these years all of the popular browsers will expose Javascript APIs that provide HTTP client functionality on par with the Apache HTTP Client, but we’ve got a ways to go.

In the meantime, I found this extremely useful and interesting page by Mark Nottingham that tests the correctness of your browsers’ XHR caching. Try it with a couple of different browsers and observe the differences.