A reverse proxy with redis cahing
Project description
Markdown
cacheproxy ⚡
A high-performance command-line reverse proxy that automatically intercepts HTTP requests and caches them in Redis. Built with FastAPI, Typer, and Async Redis.
Features
- Smart Caching: Automatically caches safe
GET200 responses for 24 hours. - Header Optimization: Seamlessly handles browser headers (strips encodings to prevent decoding bugs).
- Binary Safe: Uses
base64encoding to store complex body types safely in Redis strings. - On-Demand Cache Purging: Instantly flush the entire cache pool using the
/refreshendpoint. - Flexible Configuration: Fully configurable via Environment Variables or CLI arguments.
Installation
Install the utility directly via pip:
pip install cacheproxy
How to Run
1. Configure Redis (Optional)
The proxy automatically searches for a local Redis instance on port 6379. If your Redis instance lives elsewhere, pass the configuration using environment variables before running the tool:
Bash
# Linux/macOS
export REDDIS_HOST="127.0.0.1"
export REDIS_PORT="6379"
export REDDIS_DB="0"
# Windows (Command Prompt)
set REDDIS_HOST=127.0.0.1
set REDIS_PORT=6379
set REDDIS_DB=0
2. Start the Proxy
Fire up the CLI command by pointing it to your destination origin API server:
Bash
cacheproxy start --origin [http://api.yourbackend.com](http://api.yourbackend.com) --port 3000
Now target your applications/frontend to run through http://localhost:3000.
API & Testing Endpoints
Checking Cache Status
When you run a request through the proxy, check your response headers to verify the status:
Cache: HIT - Served instantly out of Redis.
Cache: MISS - Fetched fresh from the origin server and saved for next time.
Flushing the Cache
If you update your backend data and want to wipe the proxy cache clean immediately, send a POST request to the refresh route:
Bash
curl -X POST http://localhost:3000/refresh
Response:
JSON
{"message": "cache cleared"}
License
MIT © 2026
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cacheproxy_byiambaka_v2-0.1.0.tar.gz.
File metadata
- Download URL: cacheproxy_byiambaka_v2-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8780da5c38867f9637479ca843f4c8e778c804f8d885d5180bd37cc33d4db2e
|
|
| MD5 |
439f96745e219a6df835065481c8877a
|
|
| BLAKE2b-256 |
564344e75c84b5047197241bfb00764b040b6f7c07968424fce23fc51eda0a92
|
File details
Details for the file cacheproxy_byiambaka_v2-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cacheproxy_byiambaka_v2-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bdebc825869c8bf11bb255e6ed7b714991ddf62247bd0aabcd4e1e8c72d5e11
|
|
| MD5 |
2211703967a71417e1ff75955d55e2d4
|
|
| BLAKE2b-256 |
b8c8a536eb7e4a4764f534977265f53d1bda3c55d3938febb538025184753a3f
|