Skip to main content

proxy-buffering

Controls response buffering from the upstream.

Category TrafficAdd it to Route, Service, Consumer, Consumer group, Global rule, Plugin configEngine plugin proxy-bufferingPriority 21991

What 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.

proxy-buffering · as the console saves it
{
"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 response bufferingdisable_proxy_bufferingbooleandefault false

On, the upstream's answer is passed to the client as it arrives instead of being read in full first.

Every plugin also has Enabled, Priority, Filter, Error response and Pre-function: see Plugin execution settings.

G8 dev · Apache APISIX® 3.19.0
Apache, Apache APISIX and APISIX are trademarks of The Apache Software Foundation.
Facts
Category
Traffic
Add it to
Route, Service, Consumer, Consumer group, Global rule, Plugin config
Engine plugin
proxy-buffering
Priority
21991