Response caching that respects your existing FastAPI app.¶
Start with a single decorator. Keep your existing fastapi_cache imports. Get tested Redis compatibility, safer HTTP behavior, clear migration paths, and evidence-backed releases.
-
Build something new
Install a pinned package, run an InMemory example, see real HIT/MISS headers.
-
Already using fastapi-cache2?
Keep most imports and decorators; review the intentional privacy changes and clean rollback.
-
Choose your backend
InMemory for a single worker, or standalone Redis to share entries across workers.
-
Protect private responses
Authenticated requests bypass by default. Header variation is explicit, not automatic tenant isolation.
Install the published version¶
python -m pip install "fastapi-cache-stable==0.7.1" uvicorn
python -m pip check
The package name is fastapi-cache-stable; imports remain fastapi_cache. Use fastapi-cache-stable[redis]==0.7.1 for standalone Redis.
Do not install both packages
fastapi-cache2 and fastapi-cache-stable own the same Python package files. pip check will not detect this collision. Uninstall the old distribution in a clean environment before migrating.
What ships today?¶
| Included in published 0.7.1 | Future / not shipped |
|---|---|
| Default-key-compatible GET/JSON caching | Typed cache lifecycle events (#50) |
| Standalone Redis and process-local InMemory | Single-flight and tag-based invalidation |
| Safe default Authorization/Cookie bypass | Arbitrary hidden tenant/context autodetection (#53 residual) |
Opt-in vary_headers, ETag and HTTP 304 |
Python 3.14 certification |
| Python 3.8–3.13 functional compatibility; opt-in bounded InMemory | — |
Security-maintained target: server-side CPython 3.11–3.13. Python 3.8–3.10 are legacy functional migration targets, not security-supported runtimes. DynamoDB and Memcached remain experimental.
Release evidence: artifact provenance · Next work: 0.7 roadmap · Source: GitHub