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:
- Notices an incoming request
- Waits five seconds and responds with the headers and text “A”
- Waits five more seconds and sends “B”
- 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:
- Safari 5 – the blue progress bar appears in left side of the address bar and “contacting localhost” is displayed in the bottom left corner. After 15 seconds, bam, page is done loading and “ABC” is displayed.
- Chrome 6 – The indicator in the tab starts swirling counterclockwise, after 5 seconds it switches and starts vigorously swirling clockwise, after 15 seconds page finishes loading and “ABC” is displayed.
- Firefox 3.5 – Tab says “loading” and the bottom left says “waiting for localhost”. After 5 seconds, “A” appears on screen and bottom left says “transferring data from localhost…” After 10 seconds “B” appears, and after 15 seconds “C” appears and the page is done.
- Opera 10 – Same as Chrome except the status bar message changes. It says “sending request to localhost”, 5 seconds later that changes to “transferring”, and then after 15 seconds it displays “ABC” all at once.
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