This is a proxy application with a caching system that acts as an intermediary between the client and an external API. The application caches responses to improve performance and reduce load on the origin server.
- HTTP proxy for any external API
- Response caching system
- Flexible configuration through command-line parameters
- Cache headers to monitor hits/misses
- Option to manually clear the cache
- Node.js (version 12 or higher)
- npm (included with Node.js)
- Clone the repository:
git clone https://github.com/DPHCo/caching-proxy.git
cd caching-proxy- Install dependencies:
npm installThe application can be started with different configuration parameters:
caching-proxy --port <number> --origin <url>--portor-port: Port where the server will run--originor-origin: URL of the external API to proxy--clear-cacheor-clear-cache: Clears the cache when starting the server
- Start the server on port 3000 to proxy an API:
caching-proxy --port 3000 --origin https://pokeapi.co/api/v2- Clear the cache:
caching-proxy --clear-cacheThe application includes special headers in responses:
X-Cache: Indicates if the response was served from cacheHit: Response was served from cacheMiss: Response was obtained from the external API
- Cache is maintained in memory, so it will be lost when the server restarts
- It's recommended to use the
--clear-cacheoption when cached data might be outdated - The application is designed to handle JSON responses from the external API