System in PHP respond in Parts

2

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

ob_implicit_flush()

So any output would be sent directly to the browser's browser, as opposed to waiting for the system to finish sending everything to output.

Well, this has big impacts on performance, could this be bad in any way?

The idea is to list products, and to print as PHP gives the output (echo), so it would be possible to see some products without needing them all to be processed to successively give the output.

    
asked by anonymous 28.10.2015 / 18:49

1 answer

3

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

I think the biggest problem with this practice is the user experience, because it can be frustrating for the page to load, load, and never reach the end of the upload. Unless you adopt a progress bar or give it some kind of feedback.

It's also important to try to diagnose the bottleneck, meaning the page is taking so long to load. It may be a good idea to diagnose your SQL queries, static files (CSS, JS), HTML size, etc.

    
28.10.2015 / 19:08