This project is a caching proxy server built using Go and Redis. It forwards requests to an origin server, caches responses for faster retrieval.
- Forward Proxy: Forwards client requests to an origin server.
- Response Caching: Uses Redis to store responses for a specified time.
- Cache HIT/MISS: Displays whether the response was served from cache or the origin server.
- Go (Golang)
- Redis (for caching)
- Go (>=1.21)
- Docker (to run Redis in a Docker container)
-
Clone the repository:
git clone https://github.com/<user_name>/proxy_server.git cd proxy_server
-
Install the dependencies:
go mod tidy
-
Run the redis docker compose file:
docker compose -f redis_docker_compose.yml up -d
-
Start the proxy server:
go run server.go --port 3000 --origin http://dummyjson.com
You can change the port no. and the orgin server url.
curl -v http://localhost:3000/some_path
- If the response is cached, you'll see
Cache HIT
. - If the response is fetched from the origin, you'll see
Cache MISS
.
Read more about this project here!