2

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

1
  • It makes no sense at all to me that this isn't an option. It should be the default. It makes no sense that to be able to buffer the response you have to buffer the entire response before even starting the client side. It should be a built in to immediately start sending AND buffer everything that comes from the server that comes in faster than the client can receive Commented Jan 9, 2024 at 6:01

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.