When people think real-time their thoughts immediately leap to web-sockets. For many use-cases there exists a more productive approach, with good browser support hitting 100% via shims. Meet: EventSource AKA server-sent-events!
EventSource is a HTTP based protocol that allows one-way evented communication from the server to the client. It avoids the overhead of polling, provides seamless reconnection without any code on your part and has an incredibly simple API.
I'll take you through both the client and server-side of a chat application implemented via EventSource. We'll use AngularJS in the client and NodeJS in the server.
First - let's check out the EventSource API itself: