BigPipe environment requirements

Last updated on
23 March 2017
  • BigPipe uses streaming, this means any proxy in between should not buffer the response: the origin needs to stream directly to the end user.
  • Hence the web server and any proxies should not buffer the response, or otherwise the end result is still a single flush, which means worse performance again.
  • BigPipe responses contain the header Surrogate-Control: no-store, content="BigPipe/1.0". For more information about this header, see https://www.w3.org/TR/edge-arch/.

Note that this version number (BigPipe/1.0) is not expected to increase, since all that is necessary for a proxy to support BigPipe is the absence of buffering. No proxy requirements are expected to be added in the future.

Apache

Apache with mod_php

When using Apache with mod_php, there is nothing to do: no buffering by default.

Apache with PHP-FPM (FastCGI)

When using Apache with PHP-FPM (via FastCGI), you must disable FastCGI buffering.

There are several FastGCI modules for Apache:

mod_fcgid (Apache 2.2)

Set FcgidOutputBufferSize to 0:

<IfModule mod_fcgid.c>
  FcgidOutputBufferSize 0
</IfModule>
mod_fastcgi (Apache 2.2)

Add the -flush option to the FastCGIExternalServer directive:

<IfModule mod_fastcgi.c>
  FastCGIExternalServer /usr/sbin/php5-fpm -flush -socket /var/run/php5-fpm.sock
</IfModule>
mod_proxy_fcgi (Apache 2.4)

This module doesn't support disabling output buffering entirely, but will pass through a response according to PHP's output_buffering setting, so BigPipe works fine with this module out of the box, as long as gzip is disabled (e.g. SetEnv no-gzip 1).

Nginx with PHP-FPM (FastCGI)

BigPipe sets a X-Accel-Buffering: no header, which automatically disables fastcgi_buffering and gzip in Nginx >= 1.5.6.

IIS

When using IIS, you must disable its buffering.

Varnish

When using Varnish, the following VCL disables buffering only for BigPipe responses:

Varnish 4

sub vcl_backend_response {
  # Disable buffering only for BigPipe responses
  if (beresp.http.Surrogate-Control ~ "BigPipe/1.0") {
    set beresp.do_stream = true;
    set beresp.ttl = 0s;
  }
}

Varnish <4

sub vcl_fetch {
  # Disable buffering only for BigPipe responses
  if (beresp.http.Surrogate-Control ~ "BigPipe/1.0") {
    set beresp.do_stream = true;
    set beresp.ttl = 0s;
  }
}

Note that the big_pipe_nojs cookie does not break caching. Varnish should let that cookie pass through.

Nginx (as a reverse proxy)

BigPipe sets a X-Accel-Buffering: no header, which automatically disables fastcgi_buffering and gzip in Nginx >= 1.5.6.

Alternatively, it is possible to disable proxy buffering explicitly.

Other web servers and (reverse) proxies

Other web servers and (reverse) proxies, including CDNs, need to be configured in a similar way.

Buffering will nullify the improved front-end performance. This means that users accessing the site via a ISP-installed proxy will not benefit. But the site won't break either.