Skip to content

drona-gyawali/Cache-Proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cache-Proxy-Server

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.

Image

Key Features

  • 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-API headers.


How to Implement It (Quick Start)

Screencast.from.2026-05-23.17-41-12.webm
  1. Clone the repository:
git clone https://github.com/drona-gyawali/Cache-Proxy.git
cd Cache-Proxy
  1. Configure your environment: Copy .env.example to .env and set your secret token. Register your allowed external API domains in config/local.yaml.
  2. Boot up the server:
go run cmd/cache_proxy/main.go
  1. Warm the Cache
go run cmd/cache_proxy/main.go --port 8080 --origin https://dummyjson.com/comments
  1. 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.)

About

A lightweight, high-performance in-memory caching server built from scratch in Go.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages