Delay until server-sent events runEvent binding on dynamically created elements?How do I implement basic “Long Polling”?Convert HTML + CSS to PDF with PHP?How to debug JavaScript / jQuery event bindings with Firebug or similar tools?What's the difference between '$(this)' and 'this'?How to decide when to use Node.js?WebSockets vs. Server-Sent events/EventSourceIs the recommendation to include CSS before JavaScript invalid?What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?Server-sent events and php - what triggers events on the server?

When were female captains banned from Starfleet?

Freedom of speech and where it applies

Existing of non-intersecting rays

Closed-form expression for certain product

How to explain what's wrong with this application of the chain rule?

Create all possible words using a set or letters

Is it possible to put a rectangle as background in the author section?

Added a new user on Ubuntu, set password not working?

How can "mimic phobia" be cured or prevented?

Is there a name for this algorithm to calculate the concentration of a mixture of two solutions containing the same solute?

Count the occurrence of each unique word in the file

Electoral considerations aside, what are potential benefits, for the US, of policy changes proposed by the tweet recognizing Golan annexation?

Can I sign legal documents with a smiley face?

Why should universal income be universal?

Not using 's' for he/she/it

Problem with TransformedDistribution

Why electric field inside a cavity of a non-conducting sphere not zero?

Loading commands from file

Is the U.S. Code copyrighted by the Government?

How should I respond when I lied about my education and the company finds out through background check?

Has any country ever had 2 former presidents in jail simultaneously?

What is the evidence for the "tyranny of the majority problem" in a direct democracy context?

The IT department bottlenecks progress. How should I handle this?

What should you do when eye contact makes your subordinate uncomfortable?



Delay until server-sent events run


Event binding on dynamically created elements?How do I implement basic “Long Polling”?Convert HTML + CSS to PDF with PHP?How to debug JavaScript / jQuery event bindings with Firebug or similar tools?What's the difference between '$(this)' and 'this'?How to decide when to use Node.js?WebSockets vs. Server-Sent events/EventSourceIs the recommendation to include CSS before JavaScript invalid?What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?Server-sent events and php - what triggers events on the server?













0















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?










share|improve this question


























    0















    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?










    share|improve this question
























      0












      0








      0








      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?










      share|improve this question














      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?







      javascript php server-sent-events






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 7:39









      AlexAlex

      362




      362






















          1 Answer
          1






          active

          oldest

          votes


















          1














          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.)






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55038430%2fdelay-until-server-sent-events-run%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            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.)






            share|improve this answer



























              1














              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.)






              share|improve this answer

























                1












                1








                1







                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.)






                share|improve this answer













                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.)







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 10 at 4:58









                Darren CookDarren Cook

                17.2k869160




                17.2k869160





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55038430%2fdelay-until-server-sent-events-run%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    1928 у кіно

                    Захаров Федір Захарович

                    Ель Греко