A lightweight, high-performance in-memory caching server built from scratch in Go. It acts as an intermediate accelerator specifically designed for REST API requests, slashing backend response latencies down to microseconds while shielding origin servers from heavy traffic.
-
Built for APIs Only: Optimizes JSON/REST API responses, reducing subsequent request latencies from >50ms to under 1ms.
-
Thread-Safe LRU Cache: Custom-engineered Least Recently Used (LRU) eviction policy protected by mutual exclusion (
sync.Mutex) locks for safe concurrent operations. -
Domain Whitelisting: Enhances security by only forwarding requests to external domains pre-registered in
config/local.yaml. -
Token Authentication: Secure proxy access via required
X-APIheaders.
Screencast.from.2026-05-23.17-41-12.webm
- Clone the repository:
git clone https://github.com/drona-gyawali/Cache-Proxy.git
cd Cache-Proxy
- Configure your environment:
Copy
.env.exampleto.envand set your secret token. Register your allowed external API domains inconfig/local.yaml. - Boot up the server:
go run cmd/cache_proxy/main.go
- Warm the Cache
go run cmd/cache_proxy/main.go --port 8080 --origin https://dummyjson.com/comments
- Test the API Cache:
curl -i \
-H "X-API: YOUR_TOKEN_HERE" \
"http://localhost:8080/proxy?url=https://dummyjson.com/comments"
(Note: The first request will fetch from the origin server, while the second will load instantly from the memory cache.)
