Skip to main content

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 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:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cacheproxy_byiambaka_v2-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cacheproxy_byiambaka_v2-0.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

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

Hashes for cacheproxy_byiambaka_v2-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e8780da5c38867f9637479ca843f4c8e778c804f8d885d5180bd37cc33d4db2e
MD5 439f96745e219a6df835065481c8877a
BLAKE2b-256 564344e75c84b5047197241bfb00764b040b6f7c07968424fce23fc51eda0a92

See more details on using hashes here.

File details

Details for the file cacheproxy_byiambaka_v2-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cacheproxy_byiambaka_v2-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2bdebc825869c8bf11bb255e6ed7b714991ddf62247bd0aabcd4e1e8c72d5e11
MD5 2211703967a71417e1ff75955d55e2d4
BLAKE2b-256 b8c8a536eb7e4a4764f534977265f53d1bda3c55d3938febb538025184753a3f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page