A simple HTTP caching reverse proxy server built with Node.js and Express.
caching-proxy acts as a caching layer in front of your origin server. It efficiently caches GET requests for faster subsequent responses while forwarding other requests to the original backend. This project is designed for learning about HTTP caching, proxies, and middleware in Node.js.
- Caches GET responses to reduce latency and load on the origin server.
- Supports custom cache TTL (time-to-live).
- Forwards all HTTP methods to the origin if not cached.
- Stores and returns response headers.
- Adds an
X-Cacheheader to show cache HIT or MISS. - Easy to configure and extend.
-
Clone the repository:
git clone https://github.com/your-username/caching-proxy.git cd caching-proxy -
Install dependencies:
npm install
-
Build the project:
npm run build
-
Link the executable globally (for development/testing):
npm link
-
Run the caching proxy via CLI:
caching-server --origin http://example.com --port 8080
Replace
http://example.comwith your origin server URL, and8080with your desired port.
Once running, send your API requests to http://localhost:8080 (or your chosen port). The proxy will forward and cache responses from the specified origin server.
See the full project and learning roadmap at:
https://roadmap.sh/projects/caching-server
Contributions are welcome! Fork the repo and submit a pull request for improvements.
MIT