Skip to content

Learnobug/CacheProxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reverse Proxy with Caching

Project URL

https://github.com/Learnobug/CacheProxy

This project is a simple reverse proxy server built with Spring Boot. It forwards incoming requests to a configurable origin server and caches the responses to improve performance and reduce the load on the origin.

Features

  • Request Forwarding: Forwards all incoming requests to a specified upstream server.
  • Response Caching: Caches responses from the origin server to provide faster responses for subsequent identical requests.
  • In-Memory and Disk Cache: Utilizes both an in-memory cache for quick access and a disk-based cache for persistence.
  • LRU Cache Eviction: The in-memory cache uses a Least Recently Used (LRU) eviction policy to manage its size.
  • Cache-Status Header: Adds an X-Cache header to the response, indicating a cache HIT or MISS.
  • Configurable Origin: The upstream origin URL can be easily configured in the application properties.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Java 17 or newer
  • Maven 3.2+

Running the Application

  1. Clone the repository:

    git clone https://github.com/Learnobug/CacheProxy
    cd new_p
  2. Package the application: Build the project and create the executable JAR file:

    mvn package
  3. Run the application: Run the application from the created JAR file. You can specify the origin server URL as a command-line argument.

    java -jar target/new_p-0.0.1-SNAPSHOT.jar --origin.url=http://localhost:3000

    The proxy server will start on http://localhost:8080 and forward requests to http://localhost:3000.

Endpoints

All requests sent to the proxy server will be forwarded to the configured origin URL.

  • URL: /**
  • Method: All HTTP methods are supported.

For example, a request to http://localhost:8080/users/1 will be forwarded to https://api.example.com/users/1.

Built With

  • Spring Boot - The framework used to create the application.
  • Spring WebFlux - Used for making non-blocking requests to the origin server.
  • Maven - Dependency management.

Reference

This project was inspired by the Caching Server project idea on roadmap.sh.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages