in reply to HTML5, SSE, flush output '$| = 1' not working as expected

I guess that Apache will try to parse your headers and thus waits until your script exits.

I would investigate on whether you need to output a HTTP status line to make Apache ignore your output or if you need to configure Apache differently ("non-parsed headers", NPH).

In general, Server-Sent Events work, as I've written a Dancer/Plack application HTTP::ServerEvents. If you're not tied to Apache, maybe you can run this or Plack::App::EventSource by vti.

  • Comment on Re: HTML5, SSE, flush output '$| = 1' not working as expected

Replies are listed 'Best First'.
Re^2: HTML5, SSE, flush output '$| = 1' not working as expected
by ehaase (Initiate) on Sep 06, 2015 at 11:01 UTC

    Thanks Corion, you brougth me on the way of success. Turning off mod_deflate in the Apache2 configuration was the key.

    a2dismod deflate apache2 restart

    The module mod_deflate does the buffering. Turning that module of will provide updates with the Perl-Environment every second as expected.

Re^2: HTML5, SSE, flush output '$| = 1' not working as expected
by ehaase (Initiate) on Sep 05, 2015 at 14:34 UTC

    I assume that the problem is may not the Apache Server. The given sample in PHP5 works with the same server and the flush() is initiated by PHP as i think it is implemented in my sample code using Perl.

      I think the problem is the web server, on my Win8.1 desktop with IIS6.2 it updates every 10 seconds as multiples but with Apache2 it works correctly every second. If I set $| = 0; on Apache it updates every 10 seconds the same as IIS.

      What value is this line in your php.ini

      output_buffering=??
      poj