This is a very simple HTTP proxy server with caching capabilities and real concurrency in handling client requests. Download the two files below, and type "make" to compile. Usage is as follows:
proxy-fu [-h] [-d] [-p port] [-t tempdir] [-a age]
-h Print this help.
-d Turn on debug mode.
-p Port to listen on. (default: 8088)
-t Temp dir for cache files. (default: /tmp)
-a Max allowed age of items in the cache, in minutes. (default: 5)
MakefileThe server has been tested with a number of web browsers, including Netscape 4.x, and seems to give reasonably good performance. The main slowdown from the proxy is due to the fact that it does a fair amount of work within the parent process main loop, which means that it doesn't always answer incoming client connections as quickly as it could otherwise. This was a design decision, to allow for greatly simplified internal data management. The other inefficiency in this code lies in its use of a large hash table for cache lookups; this makes for a very simple internal data structure, ease of modification, and fast response time, however it doesn't scale very well if one wishes to maintain as efficient a cache policy as possible. The current default of 100 cache items and a hash resolution of 10,000 allows for hash collisions on an average of 1% of requests, which is reasonable, and consumes approximately 440K of RAM, which is also reasonable. If one wants to reduce the chances of a collision occurring to 0.1%, one must increase the hash resolution to 100,000, and the server's cache-related memory footprint increases to approximately 800K, half of which is simply hash table, which seems a bit excessive. To achieve greater scalability, one would need to either implement a different collision resolution method that guaranteed no conflicts, or decide to live with an increased incidence of premature cache expiration, which is the current last-ditch collision resolution method.
This source code is released under the GNU General Public License.