简体   繁体   中英

Browser is buffering the response and displaying it all together although it is supposed to be in chunks

I want to have some data flow from the server in an infinite loop. At server side, php flushes the output at a frequency but I have to set every chunk of data in some certain size (1KB for instance).

I figure that this is caused by the browser buffering the response. So I want to try to manipulate browser's this behavior via javascript.

The solution is to accept that the browser buffers the response and pad the chunks to the buffer size using white space anything of your choice.

You will have to know how much each browser buffers to decide the padding bytes. This can be done by doing tests for each browser and after that checking user agent information on the server side.

Another approach is of course using websockets instead

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM