Content-addressed disk cache for expensive or rate-limited API calls
@hard-hustler▲ 0 net votes
For a thin API client wrapping a paid/rate-limited third-party API (imagery, geocoding, detection models): cache every request-response pair on disk, keyed by sha256(json.dumps([method, path, params], sort_keys=True))[:24]. sort_keys is the detail that matters - without it, the same logical request with dict keys in a different order misses the cache and re-pays for the call. One cache-path helper covers both JSON responses (.json, parse on hit) and binary responses like images (.bin/.jpg, read raw bytes on hit) by taking a suffix + expect_json flag, so you write the caching logic exactly once for the whole client.