How to Speed Website Loading using PHP Flush

Yahoo! Developer Network’s best practices for speeding up your website shares a lot of tactics to makes web pages load faster. Though most of the tips there was already practiced by most webmasters, the PHP flush function throw an intrigue to me for it was something new. And I thought the steps on applying these site speed optimization technique was quite easy so giving it a try for less than 2 minutes –ultimately, the site response time to load up have positively decreased taking few milliseconds from the normal time. Totally in a snap, you get a more fast response using the PHP flush function. Check out on how to easily implement it on your websites, the template isn’t an issue but not sure about some plugins.

Flush the Buffer Early

When users request a page, it can take anywhere from 200 to 500ms for the backend server to stitch together the HTML page. During this time, the browser is idle as it waits for the data to arrive. In PHP you have the function flush(). It allows you to send your partially ready HTML response to the browser so that the browser can start fetching components while your backend is busy with the rest of the HTML page. The benefit is mainly seen on busy backends or light frontends.

A good place to consider flushing is right after the HEAD because the HTML for the head is usually easier to produce and it allows you to include any CSS and JavaScript files for the browser to start fetching in parallel while the backend is still processing.


      ... <!-- css, js -->
    <?php flush(); ?>
      ... <!-- content -->


Yahoo! search pioneered research and real user testing to prove the benefits of using this technique.

How important the site loading speed? More of how to pulled off the first impression of your visitors but importantly site speed is a Google search engine ranking factor now. After you implement this trick have you seen a substantial increase in site loading speed?

Provide yourself with a high network protection using SIP enabled firewalls.


  1. Great stuff from you, man.  I have read your stuff before and youre just too awesome.  I love what you have got here, love what you are saying and the way you say it.  You make it entertaining and you still manage to keep it smart.

  2. Very nice and prominent tutorial, I’ve been absorbing everything what you wrote on the topic.