Simulating Low Bandwidth Browsing

When designing a web-based product (or even just laying out a web page), it can be usefult to test out your pages on connections of various bandwidth. Does your page load fast enough for someone with a dial-up modem, for example? The drawback of doing this is you need to find various kinds of connections to test, which can be a huge pain. This document describes how to "trottle down" your browser connection to approximate a slower connection type.

Approach

The Apache HTTP server is used as a proxy server, sitting between your browser and the rest of the world. A special module is installed into Apache that "throttles" the connection (i.e. limits rate of data passing through the proxy server). This module is configurable to allow various speed limits.

Install Apache

You need to first download and install Apache. These instructions assume a Win32 operating system, but Apache will run on most machines. (If you have Mac OS X, Apache is pre-installed.) You will need to follow the instructions to download and install Apache for Windows or your OS of choice. When using Apache for this purpose, it will probably most useful to avoid setting up Apache as a service and instead use the command line to run it.

Configure as a Proxy

You are going to use Apache as a "proxy server". Normally, when you browse to a web page (say http://www.divnull.com, your browser makes a request directly to the target web server (DivNull's, in this case). When using a proxy server, your requests first go to the proxy server, then to the target server. When the results come back, they are sent to the proxy server, which forwards them to your browser. Proxy servers are mostly use for security reasons, where a company wants to filter, monitor or restrict traffic in and out of their network. As a "man in the middle", they can also be used for the purpose here: to control load.

To turn your Apache installation into a proxy server, you need to make some changes to its httpd.conf file. This file controls how Apache runs and, on Windows machines, is found in the conf folder within the main Apache folder. (On *nix machines, including Mac OS X, this file is usually found in /etc/httpd/conf.) This file should already have all of the lines needed to make Apache a proxy server; you just need to uncomment them.

The first line to uncomment is about a fifth of the way down:

LoadModule proxy_module modules/mod_proxy.so

In the section just past that, uncomment this line:

AddModule mod_proxy.c

Almost all the way to the bottom, you will find an entire section that needs uncommenting, starting with the line <IfModule mod_proxy.c>. Make this section look like this:

<IfModule mod_proxy.c>
   ProxyRequests On

   <Directory proxy:*>
      Order deny,allow
      Deny from all
      Allow from 127.0.0.1
   </Directory>

   #
   # Enable/disable the handling of HTTP/1.1 "Via:" headers.
   # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
   # Set to one of: Off | On | Full | Block
   #
   ProxyVia On

   #
   # To enable the cache as well, edit and uncomment the following lines:
   # (no cacheing without CacheRoot)
   #
   CacheRoot "D:/Programming/Projects/Apache/Apache/proxy"
   CacheSize 5
   CacheGcInterval 4
   CacheMaxExpire 24
   CacheLastModifiedFactor 0.1
   CacheDefaultExpire 1
   #NoCache a-domain.com another-domain.edu joes.garage-sale.com

</IfModule>

Of interest in this section is the Allow from line. This use of the proxy server is really only to be used from your own machine. The address 127.0.0.1 is a special address that always means "this machine". So, by setting Deny from to all and Allow from to 127.0.0.1, you are saying "only allow this machine to use this proxy server".

Setup Browser

You have to tell your browser to use a proxy server. Each browser has its own way of doing this, all of which are similary. To do this on Internet Explorer, do the following:

  1. Choose Internet options&elips; from the Tools menu.
  2. In the dialog that comes up, move to the Connections tab.
  3. Click the LAN Settings&elips; button.
  4. In the dialog that comes up, check the "Use proxy server&elips;" check box.
  5. Enter "localhost" in the Address field.
  6. Enter "80" (or whatever port you assigned to Apache) in the Port field.
  7. Click OK.
  8. Click OK.

You browser is now set to send all requests through the proxy server. Note that this means that the proxy server must be running to browse. If it is not, you will get page not found errors for every page you hit.

Setup Throttle

So far, we have just setup the proxy server to browse at full speed. We next need to install the throttle module to slow the server down. There are several modules that do this, but these instructions use one called mod_throttle.

Take a look at mod_trottle and follow the instructions. This invloves some compiling, so you will need a compiler to build this module.