Alex
Alex

Reputation: 101

Delay until server-sent events run

I'm building my very first server-sent events implementation using this tutorial https://www.w3schools.com/html/html5_serversentevents.asp

Works fine. But it takes up to 40 seconds until the first message is being sent. How can I get this faster?

Upvotes: 0

Views: 57

Answers (1)

Darren Cook
Darren Cook

Reputation: 28928

Instead of flush(); use @ob_flush();flush();

ob_flush() (see http://php.net/manual/en/function.ob-flush.php) will send it out of PHP's own buffers, and then flush() tells the web server (e.g. Apache) to send it on to the client.

If that does not work, then you'll need to describe more about your environment (which web server, which php version, which browsers you've tried it with, what other load balancers might be involved, etc., etc.)

Upvotes: 1

Related Questions