title: How does incoming mail notification on Gmail works?
body: <p>I'm wondering how it's implemented in Gmail, that every time you receive e-mail, the list of mails is automatically refreshed. It looks like the server is sending some kind of event to the browser, but how is it possible? Or maybe it’s simle: the browser ask the server for new messages every let’s say 2 seconds? But it would probably kill the performance…</p>
  <p>Anyone have some ideas?</p>
  <p>EDIT: OK, so if it's the simple answer, how do they manage performance? When I send an email from an other account to the gmail account the view is &quot;refreshed&quot; almost instantly. You were saying about a simple function that returns true / false, but it must have some logic (db connection or reads some files). How they manage it?</p>
  <hr />
  <h3>See also: <a href="https://stackoverflow.com/questions/732705/how-is-gmail-chat-able-to-make-ajax-requests-without-client-interaction">How is GMail Chat able to make AJAX requests without client interaction?</a></h3>