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.
- 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-Cacheheader to the response, indicating a cacheHITorMISS. - Configurable Origin: The upstream origin URL can be easily configured in the application properties.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Java 17 or newer
- Maven 3.2+
-
Clone the repository:
git clone https://github.com/Learnobug/CacheProxy cd new_p -
Package the application: Build the project and create the executable JAR file:
mvn package
-
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:8080and forward requests tohttp://localhost:3000.
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.
- Spring Boot - The framework used to create the application.
- Spring WebFlux - Used for making non-blocking requests to the origin server.
- Maven - Dependency management.
This project was inspired by the Caching Server project idea on roadmap.sh.