Server Sent Events

SSE enables unidirectional communication from the server to the client.

Note the format of the string. As the PHP script gets timed out (30s for some), it is restarted and the count begins from 0 again.
RESETRUNFULL
<?php    // SSE.php
header("Content-Type: text/event-stream");
$T = time();
while (1) {
  echo 'data: ' . (time()-$T). "\n\n";
  ob_flush(); flush();
  sleep(1);
}
?>

<!DOCTYPE html><html><body>
   <p></p>
   <script>
      var sse = new EventSource("/shared/sse.php");
      sse.onmessage = function(e) {
         document.querySelector('p').innerHTML=e.data;
      }
      sse.onopen = new function(e){};
      sse.onerror = new function(e){};
      var rs = sse.readyState;
      var url = sse.url;
   </script>
</body></html>