System in PHP Reply in Parts

Asked

Viewed 56 times

2

I saw that it is possible to make a system in PHP that responds in parts, I did not apply, but basically would use this function:

ob_implicit_flush()

So any output would be sent directly to the browser of the browser, as opposed to waiting for the system to finish to send everything to output.

Well, this has big impacts on performance, it could be bad somehow?

The idea is to list products, and go printing as PHP der the output(echo), so you could see some products without needing all were processed to successively give the output.

1 answer

3

From the point of view of a TCP connection, there is no problem. What happens when you send the answer in parts, rather than a single answer, is that the transport layer creates a buffer with the data and only fires when ordered (ie when a call occurs ob_flush, for example).

I believe that the biggest problem of this practice is the user experience, because it can be something frustrating the page loading, loading, and not arrive at the end of the load ever. Unless you adopt a progress bar or give it some kind of feedback.

It is also important to try to diagnose the bottleneck, that is, because the page is taking so long to load. It might be a good idea to diagnose your SQL queries, static files (CSS, JS), HTML size, among other things.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.