| Crates.io | hybrid_cache_server |
| lib.rs | hybrid_cache_server |
| version | 0.1.8 |
| created_at | 2025-11-22 20:10:34.06154+00 |
| updated_at | 2025-11-29 21:07:10.528626+00 |
| description | A hybrid cache server with indexing. |
| homepage | |
| repository | https://github.com/spider-rs/hybrid-cache-server |
| max_upload_size | |
| id | 1945701 |
| size | 110,969 |
A small Rust service that acts as a Chrome-aware cache indexing server:
You send it HTTP responses (with your own resource_key / website_key) and it:
resource_keywebsite_keyMake sure to have Rust. Rocksdb, and Meilisearch installed.
cargo install hybrid_cache_server./start.shwebsite_key
Represents a site-level identifier. Examples:
"example.com""https://example.com"This is used to group resources so you can ask: “give me everything for this website”.
resource_key
A unique cache key per resource (you generate this on the producer side, typically from your put_hybrid_cache logic).
Examples:
GET:https://example.com/GET:https://example.com/style.cssGET:https://cdn.example.com/jquery.js::Accept:text/javascriptWhatever you use here must match the key you pass to put_hybrid_cache(cache_key, ...).
file_id
Internally computed as blake3(body_bytes) and hex-encoded.
All bodies with the same content share the same file_id and are stored once in RocksDB.
Internally we use these key prefixes:
file:{file_id} → JSON-encoded FileEntry (the raw body bytes)res:{resource_key} → JSON-encoded ResourceEntry (metadata, including file_id)site:{website_key}::{resource_key} → empty value used as an index to quickly scan all resources for a siteThis layout lets us:
file:{file_id} reused across many resources)resource_keys for a given website_key via prefix iterationAll endpoints are under /cache/*.
POST /cache/indexIndex a single resource (one HTTP response).
Request
Headers:
X-Cache-Site: example.comwebsite_key if present.Body: JSON CachedEntryPayload:
{
"website_key": "example.com", // optional; can come from header or derived from URL
"resource_key": "GET:https://example.com/style.css",
"url": "https://example.com/style.css",
"method": "GET",
"status": 200,
"request_headers": {
"Accept": "text/css"
},
"response_headers": {
"Content-Type": "text/css; charset=utf-8"
},
"body_base64": "LyogY3NzIGJvZHkgKi8K"
}
docker build -f docker/Dockerfile.ubuntu -t hybrid-cache:ubuntu --build-arg BIN_NAME=hybrid_cache_server .
docker run -p 8080:8080 -p 7700:7700 -e MEILI_MASTER_KEY=masterKey hybrid-cache:ubuntu