https://github.com/ryankaleligabriel/proxyvault
A CLI caching proxy server.
https://github.com/ryankaleligabriel/proxyvault
docker nodejs redis
Last synced: about 2 months ago
JSON representation
A CLI caching proxy server.
- Host: GitHub
- URL: https://github.com/ryankaleligabriel/proxyvault
- Owner: RyanKaleliGabriel
- Created: 2024-11-16T08:03:45.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-11-18T10:48:36.000Z (6 months ago)
- Last Synced: 2025-01-29T10:17:09.790Z (4 months ago)
- Topics: docker, nodejs, redis
- Language: TypeScript
- Homepage: https://roadmap.sh/projects/caching-server
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# Caching Proxy
> This is a command line interface(CLI) tool that starts caching proxy server, it forwards requests tot he actual server and caches the responses. If the same request is made again, it will return the cahed response instead of forwarding the request to the server.
## Table of Contents
- [Take Aways](#take-aways)
- [Requirements](#requirements)
- [Additionals](#additionals)
- [Stack](#stack)
- [Usage](#usage)
- [Installation](#installation)
- [Example Commands](#example-commands)
- [Using Docker](#using-docker)
- [Expected Output](#expected-output)
- [Data display](#data-display)
- [Project URL](#project-url)## Take Aways
- Understanding how caches work
- Building a caching proxy server to cache responses from other servers## Requirements
User should be able to start the caching proxy server by running a command like following:
```bash
caching-proxy --port --origin
```- --port is the port on which the caching proxy server will run.
- --origin is the URL of the server to which the requests will be forwarded
- Add headers to the response that indicate whether the response is from the cache or the server
`````bash # If the response is from the cache
X-Cache: HIT#If the response is from the origin server
X-Cache: MISS
````
`````## Additionals
You should also provide a way to clear the cache by running a command like following:
```bash
caching-proxy --clear-cache
```## Stack
- Node Js
- Docker
- Redis## Usage
### Installation
1. Clone the repository
```bash
git clone https://github.com/RyanKaleliGabriel/ProxyVault.git
cd ProxyVault.git
```2. Set Environment Variables: The github API requires authentication for certain request. To avoid rate limits, you can use a personal Github access token. Create a .env file and add the your access token.
```bash
REDIS_HOST=
REDIS_PORT=
PORT=
URL=
```3. Running the CLI: Compile the typecript files then call it with the required arguements.
```bash
npm startnode dist/caching-proxy.js --port --origin
#Clearing the cache
node dist/caching-proxy.js --clear-cache
```
- [port] (required): The port on which the caching proxy server will run.
- [origin] (required): The URL of the server to which the requests will be forwarded..
- [clear-cache] (optional): Clears the cache.### Example Commands
1. Forwarding request to the origin server.
```bash
node dist/caching-proxy.js --port --origin
```2. Clearing the Cache
```bash
node dist/caching-proxy.js --clear-cache
```### Using Docker
1. Pull the image from docker hub
```
docker pull ryankaleligabriel/proxyvault-app```
2. Build the image
```
docker build -t ryankaleligabriel/proxyvault-app .
```3. Run the image
```
docker run --name -d -p 3000
```4. Check for your output
```
docker logs
```### Expected Output
```bash
1. Initial Request
Caching proxy server is running on http://localhost:3000
Forwarding requests to origin server: https://dummyjson.com
Cache miss. Fetching from origin...
Data cached2. Other requests
Caching proxy server is running on http://localhost:3000
Forwarding requests to origin server: https://dummyjson.com/products
Cache hit!
```## Data display
Data or web page will be displayed in json on http://localhost:3000 where the caching proxy server will start.
## Project URL
https://roadmap.sh/projects/caching-server