Skip to content

A Reverse proxy server which will cache your response from the main server to proxy server and give the data from own server.

License

Notifications You must be signed in to change notification settings

SAHIL-Sharma21/Cache-reverse-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Caching Reverse Proxy Server

  • A Simple caching reverse proxy server built in GOLang that caches the response from an origin server and serves caches responses to improve performance. If the requested content is cached, the server returns the cached response; if not, it fetches the response from the origin server, caches it, and forwards it to the client.

Features

  • Caching: Caches responses from the origin server to reduce the number of requests to the origin.
  • Proxy: Forwards client requests to the origin server if the requested resource is not cached.
  • CLI SUpport: Users can specify the origin server and the port for the proxy server through command-line flags.

Usage

Pre-requisites

  • Go version 1.19+ or higher
  • A running origin server from which the proxy can fetch responses.

Installation

  1. clone this repo
    git clone https://github.com/SAHIL-Sharma21/caching-proxy.git
  1. Navigate to the root directory
    cd caching-proxy
  1. Build the project
    go build -o cmd/main.go
  1. Run the server
    ./cmd/main.go --port <PORT> --origin <ORIGIN_SERVER_URL>
  • --port: The port on which the proxy server will listen for requests.(default: 8080)
  • --origin: The origin server's base URL to which requests will be forwarded when the response is not cached.

Example

    ./cmd/main.go --port 8080 --origin https://jsonplaceholder.typicode.com

Testing the proxy server

    curl http://localhost:8080/posts/1
  • On the first request, the proxy fetches the response from the origin server and caches it.
    curl http://localhost:8080/posts/1
  • On the second request, the proxy returns the cached response.

CONTRIBUTING

Feel free to fork this project and submit pull requests for improvements, bug fixes, or additional features.

About

A Reverse proxy server which will cache your response from the main server to proxy server and give the data from own server.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages