title: How do server-sent events actually work?
body: <p>So I understand the concept of server-sent events (<code>EventSource</code>):</p>
  
  <ul>
  <li>A client connects to an endpoint via <code>EventSource</code></li>
  <li>Client just listens to messages sent from the endpoint</li>
  </ul>
  
  <p>The thing I'm confused about is how it works on the server. I've had a look at different examples, but the one that comes to mind is Mozilla's: <a href="http://hacks.mozilla.org/2011/06/a-wall-powered-by-eventsource-and-server-sent-events/" rel="noreferrer">http://hacks.mozilla.org/2011/06/a-wall-powered-by-eventsource-and-server-sent-events/</a></p>
  
  <p>Now this may be just a bad example, but it kinda makes sense how the server side would work, as I understand it:</p>
  
  <ul>
  <li>Something changes in a datastore, such as a database</li>
  <li>A server-side script polls the datastore every Nth second</li>
  <li>If the polling script notices a change, a server-sent event is fired to the clients</li>
  </ul>
  
  <p>Does that make sense? Is that really how it works from a barebones perspective?</p>