Scan your whole stack
From OX Research Newsroom
Are you using fastapi-cache-stable?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.7.1
fastapi-cache-stable was last scanned on 24 Nov 2026 at version 0.7.1. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.7.1 LATEST | 24 Nov 2026 | No rules fired |
| 0.7.0 | 24 Nov 2026 | No rules fired |
| 0.6.0 | 21 Nov 2026 | No rules fired |
| 0.5.0 | 21 Nov 2026 | Not shown |
| 0.4.1 | 20 Nov 2026 | Not shown |
Findings for v0.7.1. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.7.1; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Community-maintained fork of fastapi-cache2. The Python import stays
fastapi_cache; intentional safety/behavior changes are described in MIGRATION.md.Latest published stable: 0.7.1 on PyPI (released 2026-11-24) · Documentation · Release notes · Release evidence · Quickstart · Migration · Compatibility · Security · Support · Changelog. 0.7.1: metadata-only correction over 0.7.0. The runtime already contains exact TTL expiry, decode-before-304 and the declared Redis tuple contract. This patch rebuilds the PyPI long description from the corrected README. Pre-releases must be independently evaluated before production deployment.
Installation: Python
>=3.8,<3.14. CPython 3.11–3.13 (server-side) has security validation; Python 3.8–3.10 is functional legacy compatibility only. DynamoDB/Memcached remain experimental. Browser/Pyodide/Node are untested. Independent project, not endorsed by the upstream maintainer.
stableis the release branch;maintracks upstream.
Recommended for production: CPython 3.11–3.13, within our tested
FastAPI/Redis/InMemory matrix. Python 3.8–3.10 stays installable and
functionally tested to support migrations from fastapi-cache2, but is
legacy-only: these EOL runtimes and their dependency stacks receive
no security maintenance commitment. Known issues in some Python 3.8/3.9
dependency profiles include AnyIO TLS
and Starlette file serving.
The library does not exercise those specific paths directly, but other
application features might. Use a newer Python and patched compatible
dependencies whenever possible.
A vulnerability found in a package shared by this fork and the original
fastapi-cache2 may affect both if a consumer resolves the same vulnerable
version and invokes the affected code. They do not necessarily install
the same dependency versions. In particular, the published fastapi-cache2==0.2.2 and this fork
both declared redis-py 4.x in the published 0.3.x metadata. The upstream repository's later, unreleased
main branch changed the Redis extra to 5.x. 0.4.x now publishes
Python-conditional redis-py ranges through 8.1.x; older 0.3.x artifacts
remain unchanged.
See compatibility & risk matrix,
security policy and
legacy vulnerability explanation.
| I'm… | Start here | What you'll learn |
|---|---|---|
| Starting from zero | Install in 5 minutes · Visual guide source | Pinned package, InMemory, first HIT/MISS, Redis |
| Already on fastapi-cache2 | Migration walkthrough · Full migration contract | Remove the old distribution, validate privacy, migrate namespaces, rollback |
| Comparing features/backends | Feature matrix · Backend choice | What's actually in 0.7.1 and what remains proposed |
| Checking security | Tenant and request safety · Security policy | Default auth bypass, custom headers, cache-key isolation |
| Looking ahead | Next release plan · #95 roadmap | post-0.7 work, not publication promises |
Try it: one-command before/after migration demo (two isolated published environments, no Redis or credentials).
Published: fastapi-cache-stable 0.7.1. It includes the opt-in bounded InMemoryBackend(max_entries=...), exact TTL expiry, decode-before-304 and the declared Redis tuple contract. Read the searchable documentation site; source is in site_docs/.
fastapi-cache is a tool to cache FastAPI endpoint and function results, with
backends supporting Redis, Memcached, and Amazon DynamoDB.
The published 0.7.1 line prioritizes safe, low-friction migration over feature count. See the roadmap and its linked issues for maintenance and later opt-in work. Roadmap items are not included in 0.7.1 and are not delivery commitments.
fastapi_cache imports and legacy default cache-key algorithm.vary_headers for explicitly declared public header dimensions, with versioned hashed keys.Install the published version you have tested, pinned exactly:
python -m pip uninstall -y fastapi-cache2
python -m pip install "fastapi-cache-stable[redis]==0.7.1"
python -m pip check
The 0.7.1 release evidence records the published wheel/sdist hashes and workflows. Do not treat the repository version alone as publication evidence.
For process-local InMemory caching, omit [redis]. See the
5-minute quickstart for a complete example.
To evaluate a published pre-release candidate:
python -m pip install --pre --upgrade "fastapi-cache-stable[redis]"
Other extras: [memcache], [dynamodb] (experimental), or no extra for
InMemory. Before deploying, check PyPI
and pin the exact version you've tested. Never co-install fastapi-cache2;
both distributions provide fastapi_cache files.
The intended low-friction upgrade is fastapi-cache2==0.2.2 →
fastapi-cache-stable, keeping your existing from fastapi_cache ...
imports and usual @cache(...) calls. For GET/JSON with standalone Redis
or InMemory, the default key algorithm is unchanged. Uninstall the old
distribution first: the two packages install the same Python module and
must not coexist. Update the dependency in your application's lockfile.
This is not a promise of identical behavior in every case: authenticated
requests bypass cache by default, second init() calls now raise, and
clear(key=...) is intentionally narrower. Old private/special Redis
entries may require targeted invalidation. See the
quick migration checklist,
verification scenarios and rollback instructions.
Redis 7 / redis-py 4.x example. Initialize once per application lifespan,
then close owned resources and reset the process-global cache configuration
on teardown. Avoid routine use of force=True.
from contextlib import asynccontextmanager
from typing import AsyncIterator
from fastapi import FastAPI
from redis import asyncio as aioredis
from fastapi_cache import FastAPICache
from fastapi_cache.backends.redis import RedisBackend
from fastapi_cache.decorator import cache
@asynccontextmanager
async def lifespan(_: FastAPI) -> AsyncIterator[None]:
redis_client = aioredis.from_url(
"redis://localhost:6379/0", decode_responses=False
)
FastAPICache.init(RedisBackend(redis_client), prefix="fastapi-cache")
try:
yield
finally:
FastAPICache.reset()
await redis_client.close() # redis-py 4.x
app = FastAPI(lifespan=lifespan)
@app.get("/")
@cache(expire=60)
async def index():
return {"hello": "world"}
For a process-local test fixture, use
FastAPICache.init(InMemoryBackend(), prefix="fastapi-cache")
after importing InMemoryBackend from
fastapi_cache.backends.inmemory. InMemory data is not shared across workers.
Call FastAPICache.init() once per process at application startup. A
second call raises RuntimeError; test fixtures that re-enter a lifespan
must close owned backend resources and call FastAPICache.reset() during
teardown. force=True permits deliberate replacement but does not
close the old connection pool or isolate multiple FastAPI apps in one process.
@cache decoratorIf you want to cache a FastAPI response transparently, use the @cache
decorator between the router decorator and the view function.
| Parameter | type | default | description |
|---|---|---|---|
expire |
int |
sets the caching time in seconds | |
namespace |
str |
"" |
namespace to use to store certain cache items |
coder |
Coder |
JsonCoder |
which coder to use, e.g. JsonCoder |
key_builder |
KeyBuilder callable |
default_key_builder |
which key builder to use |
injected_dependency_namespace |
str |
__fastapi_cache |
prefix for injected dependency keywords. |
cache_authenticated |
bool |
None |
per-endpoint override for authenticated requests; requires an identity-aware key_builder. |
infer_response_model |
bool |
False |
opt into FastAPI's response-model inference from a return annotation; can enable output validation and break invalid union/Response annotations. Disabled by default for drop-in compatibility. |
vary_headers |
Sequence[str] |
None |
opt into an isolated, hashed variant cache key for the explicitly listed HTTP request headers; it does not automatically discover tenant/identity/context state. |
The cache_status_header argument belongs to FastAPICache.init(), not
@cache(). It controls the HIT / MISS response header.
You can also use the @cache decorator on regular functions to cache their result.
The cache decorator injects dependencies for the Request and Response
objects, so that it can add cache control headers to the outgoing response, and
return a 304 Not Modified response when the incoming request has a matching
If-None-Match header. The ETag is a quoted weak validator derived from a stable SHA-256
digest of the cached representation; If-None-Match supports weak comparison,
comma-separated lists and *. Conditional requests are evaluated on both hits and misses,
and malformed entity-tags are ignored. This only happens if the decorated endpoint doesn't
already list these dependencies already.
The keyword arguments for these extra dependencies are named
__fastapi_cache_request and __fastapi_cache_response to minimize collisions.
Use the injected_dependency_namespace argument to @cache to change the
prefix used if those names would clash anyway.
The default JsonCoder stores any data type that FastAPI can convert to JSON, including
Pydantic models and dataclasses. On a cache hit it returns the decoded JSON value (plain
dicts/lists), not the annotated model; this is the legacy fastapi-cache2 behavior.
Pydantic v2 users can opt into typed restoration with TypedJsonCoder:
from fastapi_cache import FastAPICache
from fastapi_cache.coder import TypedJsonCoder
FastAPICache.init(backend, coder=TypedJsonCoder)
or per endpoint:
from .models import SomeModel, create_some_model
@app.get("/foo")
@cache(expire=60, coder=TypedJsonCoder)
async def foo() -> SomeModel:
return create_some_model()
TypedJsonCoder uses the endpoint return annotation to restore the annotated type and
propagates validation errors. It requires Pydantic v2; Pydantic v1 and annotations that
cannot be represented by a Pydantic v2 schema keep the legacy decoded behavior.
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.