I am a bit confused about how php buffering works.
Let's say you have a php page foo.php
and output_buffering = 4096
in php.ini
, and Apache receives a get request for foo.php
. foo.php
starts executing, and as soon as 4096 bytes are ready, they are sent to Apache. Apache starts sending those 4096 bytes to the client.
Here's what I don't understand: what happens when there's a some nasty tracker callout, a javascript or an image that was sent to the browser. The browser gets hung up and is not talking back to Apache for a while, holding it up. Apache is not releasing MySQL thread, which is showing up as a "sleeper". Is this correct or am I completely off base here?
You're completely off base :)
what happens when there's a some nasty tracker callout, a javascript or an image that was sent to the browser
This isn't going to impact anything on the server side.
Each request that runs through PHP will
The buffering you're talking about occurs between steps 2 and 3. So, lets take your scenario.
It's the separate request that's impotent here. All PHP and Apache are doing is returning HTML to the browser. This HTML may produce an img or javasript tag that will call back to the same web-server, but those requests will be handled separately from the request that's producing the HTML for the existing page.
The browser doesn't get 'hung up' from downloading HTML data from the server. It continues to download the entire page, even if it is waiting on a JavaScript file to come down before it will actually show any of it.
Of course if the browser/server connection breaks for some reason you can get Apache hanging around waiting for ACKs until the connection times out, but this is not the usual case.
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.