A simple CLI-based caching proxy server that forwards requests to an origin server and caches responses in-memory for improved performance.
- In-memory caching with TTL support
- Cache HIT / MISS detection via logs and headers
- Forwards requests to any origin server
- Caches only
GETandHEADrequests - Preserves response headers and status codes
- Easy to test with
curlor browser
Clone the repo and install dependencies:
pnpm installRun the CLI in development mode:
pnpm dev --port 3000 --origin https://example.comCompile the project:
pnpm buildLink the cli globally:
pnpm link --globalAfter building and linking globally, run:
caching-proxy --port <number> --origin <url>caching-proxy --port 3000 --origin https://jsonplaceholder.typicode.comSend requests to your proxy:
curl -i http://localhost:3000/posts- First request →
🔴 Cache MISS - Subsequent requests →
🟢 Cache HIT
Check response headers:
x-cache: HIT | MISS- Default TTL: 50 seconds
- After expiration, cache is invalidated and refreshed
- Cache is stored in-memory (cleared on server restart)
- Only successful responses (
2xx - 3xx) are cached - Non-GET/HEAD requests bypass cache
MIT