proxy-buffering
Controls response buffering from the upstream.
proxy-bufferingPriority 21991What it does
proxy-buffering decides how the backend's answer reaches the client. With Disable response buffering on, the answer is passed to the client as it arrives, and with it off the gateway reads it in full first.
It changes when the client receives the bytes, not what it receives. The client gets the same answer either way, and with buffering off its first bytes arrive before the backend has written the last.
When to use it
- An export of a year's orders that the backend writes over a minute, where the client should start saving it at once.
- Order status updates the backend sends as a stream of events on one long answer, which the mobile app shows as they come.
- A backend that answers slowly in many small parts, where a client should see the first part before the last is written.
Not for passing a large upload to the backend as it arrives — see proxy-control (Controls request buffering for the upstream), keeping a copy of answers to serve again — see proxy-cache (Caches upstream responses on disk or in memory) or changing the status, headers or body of the answer — see response-rewrite (Rewrites the response status, headers and body).
Set it up
Stream a long-running response to the client as it arrives
Turn on Disable response buffering.
{
"disable_proxy_buffering": true
}
Things to know
- Disable response buffering — On, a response cache kept on disk (the default) stops working: every request reaches the upstream and no cache status comes back. A cache kept in memory still answers from the cache.
- AdviceTurn buffering off only on the routes whose answers are long or slow, and leave it on everywhere else.
Settings
The fields as the console shows them, section by section.
disable_proxy_bufferingbooleandefault falseOn, the upstream's answer is passed to the client as it arrives instead of being read in full first.