A multi-threaded HTTP proxy server in C with LRU cache for improved performance.
proxy_server_with_cache.c- Main implementation (authored)proxy_parse.c,proxy_parse.h- HTTP parsing utilities (from GitHub)
- Multi-threaded (up to 400 concurrent clients)
- LRU caching (200 MB cache, 10 MB max per element)
- HTTP/1.0 and HTTP/1.1 support
- Thread-safe cache operations
gcc -o proxy_server proxy_server_with_cache.c proxy_parse.c -lpthread./proxy_server <port_number>Example:
./proxy_server 8080- Client connects to proxy
- Proxy checks cache (hit = instant return)
- On miss: fetches from remote server, sends to client, caches response
- LRU eviction when cache is full
Edit these constants in source code:
#define MAX_BYTES 4096 // Max request/response size
#define MAX_CLIENTS 400 // Max concurrent clients
#define MAX_SIZE 200*(1<<20) // Cache size (200 MB)
#define MAX_ELEMENT_SIZE 10*(1<<20) // Max element size (10 MB)Firefox: Settings → Network Settings → Manual proxy configuration
- HTTP Proxy:
localhost, Port:8080
curl -x http://localhost:8080 http://example.com- HTTP GET requests only
- Error codes: 400, 403, 404, 500, 501, 505
- No HTTPS support
- GET requests only
- No persistent cache (resets on restart)
MOHD AFFAN