Search code examples
jqueryajaxtitlesetintervalinbox

Is there a more efficient way of displaying unread message number in page title?


Currently I use this...

setInterval(function() {
    $.ajax({
        url: 'data.php',
        success: function(data) { document.title = data;},
        dataType: 'text'
    });
}, 15000);

But it seems to slow down the server due to the amount of queries to the server.

Is there another way of displaying the amount of unread messages in the title bar, without the overload?


Solution

  • These solutions come to my mind:

    1. Using Server-Sent Events (Which of course, reduces scalability due to open network connections)
    2. Using Page Visibility
    3. Comet programming
    4. Explicitly offering this feature on user's demand (so that many users won't even request for it)