Tuning Firefox for Speed - enable HTTP Pipelining, and more



The Internet is amazing, if you have a server in the same country everything seems to happen almost instantly... but with many servers overseas, it's good to reduce the number of TCP round trips needed to view your web pages.

Web page authors can do all sorts of hacks to make things load faster (e.g.  check out Y-slow), but you can get great improvements just by tweaking your browser settings.  Here's how to do that with Firefox:

essential - HTTP pipelining:

1. Enter 'about:config' in the URL bar, and click 'I'll be careful'.
2. Search for 'pipe'.
3. Enable all the pipelining options, if not already.
4. Set 'network.http.pipelining.maxrequests' to 100 or some large number.

already - HTTP keep-alive:

5. Search for 'alive'.
6. Enable all the keep-alive options, if not already (they should be).
7. You can increase 'network.http.keep-alive.timeout', but not much need.

optional - paint delay, max connections:

8. Right click, new → integer, name 'nglayout.initialpaint.delay', value 0.
9. Search for 'connections'.
10. You can increase these four max-connections values, but not much need.

All these speed hacks are well-known, but the top-ranking page on Google for 'Firefox pipelining' was an incorrect blog post by someone who had completely misunderstood what HTTP pipelining is.  So maybe it's worth explaining it.

Pipelining just means your browser will send all (or many) outstanding requests at once, through a single channel; rather than the normal slow cycle: request 1, read response 1, request 2, read response 2...  So, pipelining avoids a lot of unnecessary latency, with no need to open parallel connections.

Keep-alive simply means when your browser has finished loading something, it keeps the connection to the server open, so it's ready to request the next page.  This avoids the latency of opening a new TCP connection (3-way handshake), an extra round trip.  It is enabled by default in Firefox.  Keepalive is a prerequisite for HTTP pipelining, as far as I know.

When you enable keep-alive and pipelining, you should only be waiting for perhaps two round trips per page (including all media) + the transfer time, not tens or hundreds of round trips, one or two for each image, JS file, ...

HTTP pipelining might upset some total idiot web servers, but really it's quite a challenge to write a web server that doesn't support pipelining, it's not a protocol change, you just send several requests one after the other before waiting for responses.  If you find some site that doesn't work with pipelining, please let me know!  I wrote a web server 'tachyon', which worked correctly with HTTP pipelining without any changes needed to support it.

The other key I mentioned, nglayout.initialpaint.delay = 0, just tells Firefox to start rendering the page on your screen as soon as it can.  Normally it will wait for a little while after it receives the start of the page, before rendering.  It's up to you, whether you think it's better to see the start of the page while it's still loading, or to wait until the browser has most or all of the page collected to render.  Setting the initial delay to zero can make it take a little longer to render the final page, but you will see some content sooner, it gives an impression of quickness.

I hope that this short advice, with correct explanations, will help you enjoy a better browsing experience with Firefox!  If you have some correction for me, or other browsing speed tips, please let me know and I'll update this page.

earth
Sam Watkins
2011-05-19

sam.nipl.net

sam@nipl.net