To break the question down to one sentence: Is it Possible to turn on proxy_buffering in nginx, but sending the response of the backend server immediately to the client when the client is fast enough to take and if not, to buffer it?
I know if you turn off the proxy_buffering, all requests will pass through nginx, but the backend server worker still is open until all data are send to the client. If you turn on proxy_buffering, nginx waits until the backend server is done, than begin to send the data to the client, and the backend server can close the process before the data is at the client.
To make it simple: I want the advantages of both: i want that the client get as soon as possible the first chunks of the backend server, but also i want that all data from the backend server that can't be passed to the client(e.g. slow connection) will be bufferd by nginx so the backend server process can be closed as soon as possible.
To understand WHY i need this: I have a php backend server with an application that flushes the output in sequences. So if you request a page, the HTML with css, js and so on will flush nearly immediately after the process is started, after that the "heavy" application work started and i send some part of the html in slices. So the benefit of that is that the client/browser can start to download the .js, .css and parse them before the request is finished and so i reduce the critical render path of my website.
The problem is, if proxy_buffering is on, the client will get no data to work with until the backend requst is finished. If i turn of the proxy_buffering the backend process stays open until the client receives the last data.
Thanks in advance