Fun little tidbit: Firefox, Safari, Chrome, and Opera each behave slightly differently when faced with slowly incoming incremental data.

I wrote a very short little node.js server script which basically:

  1. Notices an incoming request
  2. Waits five seconds and responds with the headers and text “A”
  3. Waits five more seconds and sends “B”
  4. Waits five more seconds, sends “C”, and closes the connection

So I fire up each browser, go to the address bar, type “localhost:8124″, hit Enter, and watch:

So it looks like Safari doesn’t do anything until all the data is downloaded (or maybe some amount of data is downloaded). Chrome and Opera both at least acknowledge they’ve heard a response from the server after sending a request, though they don’t display anything until they have it all. Firefox displayed each piece of data as it came.

Now, thinking of my browsing experiences in Safari and Chrome — they clearly display a page before it’s completely finished downloading. I don’t know why it’s different here. Perhaps there’s a minimum amount of data that needs to transfer first, or maybe the browsers parse the incoming data looking for some trigger.

Firefox, while nobly trying to display its data as fast as it can, might have to constantly redraw the page with its strategy. I wonder if I could use this behavior of Firefox as a sort of `tail` command for node.js….?


Mon, Sep 20, 2010 | For updates follow me on twitter