CacheProxy
A simple Python cache/caching proxy for Web development and something else, built on aiohttp and aiohttp-client-cache (a family project of requests-cache).
Useful to avoid unfavorable massive accesses to external APIs during development, with little change, without preparing mocks. Not recommended for production.
Install
pip install cacheproxy
Usage
1. Start up proxy
$ cacheproxy sqlite -c ./cache --expire-after 1800
Cache database: /Users/nolze/src/cacheproxy/cache.sqlite
======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit)
Other backends:
cacheproxy # in-memory
cacheproxy memory # in-memory
cacheproxy file -c ./cache # file-based, saved under ./cache/
cacheproxy sqlite -c ./cache # sqlite, saved to ./cache.sqlite
2. Access through proxy
cURL:
curl http://0.0.0.0:8080/api.github.com/repos/nolze/cacheproxy # This request is cached until the expiration time
# → {"id":...,"node_id":"...","name":"cacheproxy", ...
Python (requests):
import requests
base_url = "http://0.0.0.0:8080/api.github.com" # Just replace with "https://api.github.com" on production
resp = requests.get(f"{base_url}/repos/nolze/cacheproxy") # or use urljoin()
print(resp.json())
# → {'id': ...., 'node_id': '....', 'name': 'cacheproxy', ...
JavaScript/Node:
const baseURL = "http://0.0.0.0:8080/api.github.com"; // Just replace with "https://api.github.com" on production
const resp = await fetch(`${baseURL}/repos/nolze/cacheproxy`);
const data = await resp.json();
console.log(data);
// → Object { id: ..., node_id: "...", name: "cacheproxy", ...
Interact with or modify cached data
Use aiohttp-client-cache to load existing databases.
See also:
Todos
- Better error handling
- Write tests
- Better logging
- Support POST/PUT
- Support switching http/https (with --http/--https flags)
- Support DynamoDB, MongoDB, and Redis backends
License
MIT
Metadata
Release files for cacheproxy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cacheproxy-0.1.0.tar.gz | 5.1 kB | Without provenance | Details for cacheproxy-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cacheproxy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for cacheproxy-0.1.0-py3-none-any.whl |
Total release size: 10.6 kB
Release files / cacheproxy-0.1.0.tar.gz
| Download URL | cacheproxy-0.1.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98001fd7139e894c97ac3a56c5f2b94447c5e4feea6335fcb5d4c60cf31fb9ed
|
|
BLAKE2b-256 checksum How to use checksums |
993b4f560ccabfc6b010c2ad7b4ed64e3da60fa063de4fabf67e6a4e503ff5cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.8 Darwin/21.4.0
|
Release files / cacheproxy-0.1.0-py3-none-any.whl
| Download URL | cacheproxy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f0a0f82cc75188de608b465735baa3fd4232f5968fd1d5cb1e0090ce9a4c91c1
|
|
BLAKE2b-256 checksum How to use checksums |
9e0e71c46986d1f35c5c26d768bbb2ec72a639ff1cd8f59ab2f92b73df6ca5af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.8 Darwin/21.4.0
|
Security for cacheproxy 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.