BigPipe environment requirements

Last updated on
20 December 2019
  • 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 FastCGI 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.31)

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

mod_proxy_fcgi (Apache >= 2.4.31)

When using Apache with PHP-FPM (via mod_proxy_fcgi), you must disable buffering by setting flushpackets=on. Depending on your configuration this option has to be set on ProxyPassMatch or Proxy. When that parameter is set to "on" then the proxy module will flush after each chunk of data.

Version 1:
ProxyPassMatch "^/myapp/.*\.php(/.*)?$" "fcgi://localhost:9000/var/www/" enablereuse=on flushpackets=on
Version 2:
<FilesMatch "\.php$">
    # Note: The only part that varies is /path/to/app.sock
    SetHandler  "proxy:unix:/path/to/app.sock|fcgi://localhost/"
</FilesMatch>

# Define a matching worker.
# The part that is matched to the SetHandler is the part that
# follows the pipe. If you need to distinguish, "localhost; can
# be anything unique.
<Proxy "fcgi://localhost/" enablereuse=on flushpackets=on max=10>
</Proxy>

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 an ISP-installed proxy will not benefit. But the site won't break either.

Help improve this page

Page status: No known problems

You can: