Why long-polling request may lead to usability problems
Posted in Software Development on January 29th, 2010 by Jürgen – Be the first to commentWe are living in the Web 2.0 era, that’s where Web applications load their contents dynamically using an AJAX request or JSONP. One of the more interesting things you can do is push notifications to the browser. Instead of having a timer in the browser firing at a fixed rate, you send a request to server and don’t answer immediately. Whenever an event on the server occurs, you send a notification to the browser over this connection and close it afterwards. The browser in turn, after handling the notification, instantly sends a new request waiting for more events. Because of the nature of that request it is called long-polling. This works really fine, to avoid timeouts by routers or proxies that are between browsers and the server you can send a ‘nothing happened’ notification after a while so that the browser can build a new request.
And now come the real issues. Currently they only apply to Safari browsers. Apple is known for the outstanding usability of their products and so they had a great idea to inform users when Safari is doing background server fetches. Normally, a spinning wheel on the right end of the address field indicates that the browser is loading and during that it appears as selected. Whenever Safari retrieves resources indirectly by referencing them from within the page’s HTML, AJAX or JSONP calls, the spinning wheel does its thing and the background appears in a disabled state.
So why do you need to care about this? From a user’s perspective, the Web applications appears as it still hasn’t finished downloading yet. After a while, they refresh the site hoping this will resolve. But doesn’t refreshing the page make the AJAX obsolete? And believe me, user’s will do this. If it doesn’t go away, they turn their interest to someone else’s page, or if you are lucky, they complain.
But the real painful part for you is that the user can, even when the spinning wheel appears disabled, click on the cancel button (the cross) and stop your long-polling request forever!
And what are your workarounds? Okay, Safari users are evil, don’t care about them. Then you should at least notify them before using a browser you do not support. Another alternative is to force users to install the Yahoo! Browser Plus plug-in. This is super-simple, users don’t even need to restart the browser after installation or need administration privileges on their machines, and you get some crazy features like desktop drag’n'drop for free. Browser Plus provides a JSONRequest object that does cross-domain JSON requests in a safe manner.
Another alternative would be to rethink your application model about whether you can avoid pushing data to the browser. Creating Web applications with an exciting user experience is still a complex task. Compared to native applications, browsers, their programming model and JavaScript, are still limiting in so many ways.
Related topics:
Yahoo! Browser Plus



