Instant yet Simple PHP notification with HTML5 Server-Sent Eventssse.php<?php$dbconn = new PDO("pgsql:host=localhost;dbname=mydb", "pduser", "userpass");$dbconn->exec('LISTEN "channel_name"'); // those doublequotes are very importantheader("X-Accel-Buffering: no"); // disable ngnix webServer bufferingheader("Content-Type: text/event-stream");header("Cache-Control: no-cache");ob_end_flush(); // close PHP output buffering$inc=0;while (1) { $result = ""; // wait for one Notify 10seconds instead of using sleep(10) $result = $dbconn->pgsqlGetNotify(PDO::FETCH_ASSOC, 10000); if ( $result ) { echo "id: $inc\ndata: ".stripslashes(json_encode($result))."\n\n"; $inc++; } flush();}?>Tested with HTML+JS sample file from Mozilla web site (ssedemo.php)