A high-performance HTTP caching proxy server built in Go that forwards requests to an origin server and caches responses using Redis. When the same request is made again, it returns the cached response instead of forwarding to the origin server, significantly improving response times and reducing server load.
- HTTP Proxy: Forwards HTTP requests to any origin server
- Redis Caching: Uses Redis for fast, persistent caching of responses
- Cache Headers: Adds
X-Cache: HITorX-Cache: MISSheaders to indicate cache status - Full Request Support: Preserves headers, query parameters, and request methods
git clone https://github.com/jaykeraliya0/caching-proxy.git
cd caching-proxy
go mod tidy
go build -o caching-proxyOr install directly:
go install github.com/jaykeraliya0/caching-proxy@latestSet the Redis connection URL via environment variable:
REDIS_URL=localhost:6379For Redis with authentication:
REDIS_URL=username:password@redis-server:6379./caching-proxy start --port 3000 --origin http://dummyjson.comParameters:
--port, -p: Port on which the caching proxy server will run (required)--origin, -o: URL of the origin server to forward requests to (required)
./caching-proxy clear-cache./caching-proxy start --port 3000 --origin https://jsonplaceholder.typicode.com
# First request - Cache MISS (forwarded to origin)
curl http://localhost:3000/posts/1
# Second request - Cache HIT (served from cache)
curl http://localhost:3000/posts/1./caching-proxy start --port 3000 --origin https://httpbin.org
# Make a request (will be cached)
curl -v http://localhost:3000/get?test=123
# Check the X-Cache header in the response:
# First request: X-Cache: MISS
# Subsequent requests: X-Cache: HIThttps://roadmap.sh/projects/caching-server
⭐ If you found this project helpful, please give it a star on GitHub!