Skip to content

z7pz/caching-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Caching Proxy Server πŸš€

A high-performance caching proxy built with Rust, Axum, and Redis to improve response times and reduce API load. Supports persistent caching, compression, rate limiting, and is fully containerized with Docker.

roadmap.sh project url

πŸ“Œ Table of Contents

πŸ”§ Features

βœ… Fast caching with Redis (persistent storage)
βœ… Gzip compression for bandwidth efficiency
βœ… Configurable cache expiration (TTL)
βœ… Rate limiting to prevent abuse
βœ… Detailed logging and monitoring
βœ… Fully containerized with Docker

πŸ“₯ Installation

1️⃣ Install Manually (Rust & Cargo)

Requirements: Rust, Cargo, Redis

# Clone the repository
git clone https://github.com/z7pz/cache-proxy.git
cd cache-proxy

# Install dependencies & build
cargo build --release

# Run the proxy
./target/release/cache-proxy --port 3000 --origin "http://example.com" --cache-ttl 120

🐳 Docker Setup

2️⃣ Using Docker (Recommended)

Requirements: Docker & Docker Compose

# Build and run the container
docker compose up --build -d

To stop:

docker compose down

View logs:

docker compose logs -f cache-proxy

βš™οΈ Configuration

You can configure the caching proxy using command-line flags or Docker environment variables.

Available Options:

Flag / Env Var Description Default
--port / $PORT Server listening port 3000
--origin / $ORIGIN The origin URL to proxy "http://localhost"
--cache-ttl / $CACHE_TTL Cache expiration time (seconds) 60
--redis-url / $REDIS_URL Redis connection URL "redis://127.0.0.1/"
--clear-cache Clears Redis cache before starting false

πŸ“ Usage Examples

Run with Custom Configuration

./cache-proxy --port 8080 --origin "http://example.com" --cache-ttl 120

Clear Cache

./cache-proxy --clear-cache

Using Docker

docker run -p 3000:3000 -e ORIGIN="http://example.com" -e CACHE_TTL=120 your-image-name

πŸ›  API Endpoints

πŸ“Œ GET / (Proxy Request)

Fetches and caches responses from the origin server.

Example Request

curl -i http://localhost:3000/

Response Headers

X-Cache: HIT  # Cached response
X-Cache: MISS  # New response from origin

πŸ“œ License

MIT License. Feel free to modify and use! πŸš€

About

⚑ Rust + Axum + Redis caching proxy β€” πŸ’Ύ persistent cache Β· πŸ“¦ compression Β· 🚦 rate limiting Β· 🐳 Docker-ready

Topics

Resources

License

Stars

Watchers

Forks

Contributors