Thursday, October 13th, 2005

Browser Caching Behavior Compared

Category: Ajax

We’ve talked about the necessity of using HTTP headers to control caching of content retrieved by XMLHttpRequest on IE. Alexander Kirk takes the conversation a step further with a detailed analysis of:

the caching of downloaded code (or On-Demand Javascript, whatever you want to call it). I’ve set up a small testing suite that currently tests 3 different ways of downloading code: script-tag insertion via DOM, XmlHttpRequest as a GET and XHR as a POST.

His initial conclusion?

This gives an interesting picture: Firefox does not seem to cache any scripts, neither the ones loaded via DOM nor those loaded via XHR. Only IE loads an XHR GET request from cache.

He adds:

UPDATE: I have now included the Expires header field with the Javascript file. Now FireFox in both version caches the script with script_dom, in version 1.5b2 it also caches XHR with GET requests.

Alexander includes the full sources to his testing suite, in case you’d like to replicate it.

Posted by Ben Galbraith at 9:49 am
1 Comment

+++--
3.8 rating from 8 votes

1 Comment »

Comments feed

So far I have not found any need to download scripts via XHR, but I guess there is a need for that to… but the cache can be controlled easily, and therefore it’s a strength that files can be cached.

What I have discovered though that Firefox has severe caching problems downloading XML and XSL files via XHR in synchronous mode.

BTW, why the hell doesn’t Firefox interpret XSL files as valid XML? When downloading XSL in synchronous mode, responseHTML is set to null. Using the responseText property returns “the file”, as string…Annoying!

Comment by Hakan Bilgin — October 14, 2005

Leave a comment

You must be logged in to post a comment.