Skip to content

Troubleshooting

I see MISS on every request

Check whether FastAPICache.init() runs once per lifespan, TTL is positive, the request carries Authorization or Cookie, or your endpoint explicitly declares Request with the default builder. Each InMemory instance and each worker has its own store. Dynamic parameters with unstable repr() can create a new key on every call.

My Redis cache returns decoding errors

Use decode_responses=False, verify the installed Redis client version against the Python matrix and review any older serialized data or PickleCoder trust boundary.

I installed the fork but imports behave strangely

Ensure exactly one distribution owns the fastapi_cache module:

python -m pip show fastapi-cache2 fastapi-cache-stable
python -m pip check

A clean environment and an updated application lockfile are essential. pip check cannot detect the shared import collision.

My second application startup raises RuntimeError

The cache is process-global. Initialize once per lifespan, dispose of clients you own and use FastAPICache.reset() at teardown. Avoid force=True unless you explicitly intend to replace configuration.

My response has the wrong tenant or language

Treat this as a potential data isolation issue, not a performance glitch. Disable caching on the affected endpoint, rotate its namespace after reviewing access, inspect all hidden response dimensions and compare with privacy guidance. vary_headers is never a generic tenant isolation policy.

Can I clear an entire Redis Cluster?

Redis Cluster namespace-wide clear is unsupported. Do not assume that standalone Redis prefix scanning applies to Cluster, Sentinel, TLS or managed failover.

Can I use Python 3.14 or older EOL versions?

0.7.1 declares >=3.8,<3.14. Python 3.8–3.10 receive functional legacy tests only; modern security-maintained target is server-side 3.11–3.13. Python 3.14 is being evaluated under #51.

For a reproducible problem, open an issue with Python/FastAPI/Redis version, a minimal endpoint, expected versus actual HIT/MISS, and whether credentials or request state influence the output. Never paste real tokens or user data.