A simple HTTP proxy server with caching capabilities written in Rust. My solution to this project on roadmaps.sh.
- HTTP proxy server
- File-based response caching
- Cache control through CLI
- Support for custom origin servers
- Cache hit/miss headers
- Rust (latest stable version)
- Cargo (Rust's package manager)
Clone the repository and build the project:
git clone https://github.com/di-void/deeproxy.git
cd deeproxy
cargo build --release
To start the proxy server, use the following command:
cargo run --release -- --port <PORT> --origin <ORIGIN_URL>
Example:
cargo run --release -- --port 3000 --origin http://example.com
This will start the proxy server on http://localhost:3000
forwarding requests to http://example.com
.
To clear the cache:
cargo run clear-cache
- When a request is made to the proxy server, it first checks if the response is cached
- If cached (HIT):
- Returns the cached response with
X-Cache: HIT
header
- Returns the cached response with
- If not cached (MISS):
- Forwards the request to the origin server
- Caches the response
- Returns the response with
X-Cache: MISS
header
hyper
- HTTP server/clienttokio
- Async runtimeclap
- Command line argument parsingserde
- Serialization/deserializationsha2
- URL hashing for cache keys- And more (see
Cargo.toml
)
Build the project:
cargo build
- Only supports HTTP (not HTTPS) origins
- Basic caching implementation without cache invalidation
- No cache size limits
- Check and respect cache-control headers
- Cached data compression
- Size or memory limits for cached responses