This issue has been solved to a satisfactory level. Working example here.
Hey folks. I've been attempting to replace some AJAX stuff that refreshed every X milliseconds using the XMLHTTP object, with a streaming equivalent using inline frames and PHP delays. However, i've hit a snag in that data seems to be sent out in 4kb chunks - far too large for my intended purpose.
While this streaming example is fine providing that 4096 bytes of data is sent between each portion, this dosen't go very far towards increasing consecutive update speed and efficency (by preventing the constant cycle of connect-download-disconnect). I am aiming to only send out about 512 bytes from the server, per portion. I have yet to work out if the 4kb limit is being implemented by the client or the server.
So basically what I want to do is be able to have the code below work without needing 4kb of useless padding.
This code is not currently Moz/FF compatible, due to an issue with the way I move the content from the iframe with javascript (window.frames["streaming_iframe"].document.body.innerText returns "undefined" in FF).
// PHP consistent data streaming test. header("Cache-Control: no-cache, must-revalidate");
Solution: Inital padding with echo str_pad('',256)."\n"; (I feel that 256 bytes is an acceptable level of padding) Output flushinf with flush(); ob_flush();
Code (for possible future reference): // PHP consistent data streaming test. header("Cache-Control: no-cache, must-revalidate");
echo "";
if (@$_GET["stream"]) { echo str_pad('',256)."\n";
for ($i=0;$i<10;$i++) { echo $i."\n\r"; flush(); ob_flush(); usleep(500000); }