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

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved