A CLI caching proxy server.
CacheCruiser forwards incoming HTTP requests to a specified origin server, caches the responses on the cache instance, and returns cached responses on repeat requests to improve performance and reduce load on the origin.
This project currently implements in-memory caching and disk caching. Redis caching is planned for future releases.
- Go 1.18+ installed
- Internet connectivity
- Clone the repository:
git clone https://github.com/yourusername/cachecruiser.git cd cachecruiser - Build the binary:
go build -o cachecruiser cmd/proxy-server/main.go
./cachecruiser --port <port> --origin <origin-url>--port<number>: Port on which CacheCruiser listens (required)--origin<url>: URL of the origin server to which requests are forwarded (required)--clear-cache: Remove all cached data and exit (optional)--cache-type<type>: Type of cache to use (optional, default:memory)--cache-dir<path>: Directory to store cached data (optional, default:./disk-cache-data)
# Start the proxy on port 3000, forwarding to dummyjson.com
./cachecruiser --port 3000 --origin http://dummyjson.com
# Start the proxy with disk caching, storing cache data in a custom directory
./cachecruiser --port 3000 --origin http://dummyjson.com --cache-type disk --cache-dir /path/to/cache/data
# Start the proxy with disk caching using default cache directory
./cachecruiser --port 3000 --origin http://dummyjson.com --cache-type disk
# Clear the cache and exit
./cachecruiser --clear-cache- On first request to a given path, CacheCruiser forwards to the origin, returns the response with header:
X-Cache: MISS - On subsequent requests to the same URL, CacheCruiser serves the cached response with header:
X-Cache: HIT
CacheCruiser makes it easy to speed up repeat requests by transparently caching responses — no configuration beyond port and origin needed.
- Only GET requests are cached
- Cache keys are generated using request method + URL
- Thread-safe implementation using read-write mutexes
- Support for time-based expiration of cache entries
CacheCruiser is built with a modular design:
Cacheinterface that can be implemented by different storages (in-memory, disk, Redis, etc.)MemoryCacheimplementation for in-memory storageProxyServerfor handling HTTP requests and responses
This project is a learning exercise that comes from Roadmap.sh Caching Proxy project.
Not implemented. May come in future iterations also as a learning exercise.
- In-memory caching
- Disk-based caching
- Redis-based caching
- Configurable cache TTL via command-line flags
- Cache size limits and eviction policies
- Cache invalidation endpoints
- Tests
As this project is a learning exercise, the features listed in the roadmap may or may not be implemented in the future.