Problem with eventloop: Server sent events are buffered

I have some php code running:

header("Content-Type: text/event-stream");
header("Cache-Control: no-cache");
header("X-Accel-Buffering: no");

I was expecting this to stop nginx from output buffering, but for some reason my eventloop gets buffered.

According to the NGINX documentation (X-Accel | NGINX) the above code should be (more than) enough. But for some reason my eventloop gets all chunked up.

How can I force NGINX to listen to the header instruction? Is there a template I should change/update?


  • Dedicated server, AMD64 (12 core), 64GB RAM
  • Debian 10.9 (fresh install)
  • HestiaCP 1.4.2 (fresh install)
  • PHP7.4-FPM

If you encounter the same sort of problem: I found a workaround on stackoverflow.

Add the “flushpackets=on” option to the fcgi proxy template.

<Proxy "fcgi://localhost/" flushpackets=on></Proxy>

I do think it would be better if the header instruction would not be ignored by default.

header("X-Accel-Buffering: no");

There might be something I’m missing. If you know another way to achieve this, please let me know.

Custom template

Yes, good addition.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.