Preforking and Compressing Proxy
By Randal L. Schwartz
Back in my February 1997 column, I wrote an anonymizing proxy server in roughly 100 lines of Perl code. You could configure your browser to use the proxy, and the servers at the sites you visit wouldn't be able to discern your real IP address or other telltale identifying information (like cookies). The downside of this tiny proxy server was that every fetched URL caused a process to be forked.
If a real Web server were to do that, it'd probably be fairly narrow in application, so most modern Web servers perform preforking. That is, they fork a number of server processes ready to respond to an incoming request. Then as the requests come in, there's no latency from the time it takes to fork and get ready to listen.
Perl has enough tools to do this as well, so I decided to rewrite that proxy server as a preforking server. That alone would make it cool enough for a new column here, but I went one item better.
Most modern Web browsers accept compressed data (most commonly in the gzip format), automatically uncompressing it to display to the user. Because text compresses very well (especially large HTML pages), we can make the proxy server automatically detect a gzip-savvy browser, and compress all text downloads on the fly!
That way, if I'm running the proxy server on a machine with good Net connections (like a T-1 or better), I can use it as a speed-enhancing proxy on my normal modem links. And in fact, in practice, I found it to make downloading noticeably zippier.