Metadata-Version: 2.4
Name: cacheproxy-byiambaka-v2
Version: 0.1.0
Summary: A reverse proxy with redis cahing
Author: Aryan
License: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: fastapi>=0.115
Requires-Dist: uvicorn>=0.35
Requires-Dist: typer>=0.16
Requires-Dist: httpx>=0.28
Requires-Dist: redis>=6.2
Requires-Dist: pydantic>=2.11

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 `GET` 200 responses for 24 hours.
* **Header Optimization:** Seamlessly handles browser headers (strips encodings to prevent decoding bugs).
* **Binary Safe:** Uses `base64` encoding to store complex body types safely in Redis strings.
* **On-Demand Cache Purging:** Instantly flush the entire cache pool using the `/refresh` endpoint.
* **Flexible Configuration:** Fully configurable via Environment Variables or CLI arguments.

## Installation

Install the utility directly via pip:

```bash
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
