Skip to content

fastapi-cache-stable 0.4.1

Choose a tag to compare

@agustin18 agustin18 released this 20 Nov 16:27
· 12 commits to stable since this release
ed1000b

fastapi-cache-stable 0.4.1 — factory-route cache isolation

Status: release preparation only. Not published.
The current public PyPI release remains 0.4.0 until the manual 0.4.1
publication is completed and verified.

What's fixed

Factory-created FastAPI handlers can share the legacy default key when they
have the same module/name, arguments and namespace, even when they serve
different routes. Published 0.4.0 can therefore replay /a's cached
response from /b. 0.4.1 partitions the default cache key for:

  • functions with code free variables (co_freevars);
  • handlers wrapped by decorators that set __wrapped__, including
    functools.wraps wrappers whose factory values are bound as defaults;
  • local functions and lambdas;
  • explicitly decorated module-level handlers with __wrapped__.

The partition uses stable request method, case-normalized Host, mount root,
request path and the legacy digest. Unwrapped module-level handler keys,
the exported default_key_builder and custom builders are unchanged.
Old generated/wrapped entries are intentionally not reused; affected routes
will take an initial MISS and rotate to the new key. Read the migration guide.

Also included

  • The docs-only Towncrier classifier from #67/#71. Markdown/RST-only changes
    no longer require a fictional news fragment; source, packaging, tests,
    workflows, examples and scripts still do.
  • A changelog correction for 0.4.0: the already-shipped uvicorn removal
    (#44) and read-only Dependabot delta (#46) are now recorded.

Verification

  • Exact PR head: 0f26788dac3eced92e96b81045920163696deabb.
  • 48 unique GitHub checks green on the PR; the full Python/Redis matrix,
    lint, typecheck, security audits, wheel/sdist and CodeQL passed.
  • Dedicated HTTP regression for factory closures, functools.wraps and
    default-bound values: /a → A, /b → B, MISS/MISS/HIT/HIT.
  • Seeded old cache entries are not read; ordinary unwrapped module-level
    keys remain identical; clear(namespace=...) is covered with InMemory
    and Redis 7.
  • Final 0.4.1 wheel/sdist hashes, TestPyPI/PyPI runs and provenance are
    recorded in the release status after publication.

Limits

Generated-route keys include Host and require edge Host validation
(TrustedHostMiddleware or equivalent) to avoid fragmentation/resource
exhaustion; Host is case-normalized only, not port/alias normalized. Hidden
contextvars, middleware, tenant identity and other request context remain
the application's responsibility and are tracked in #53. Separate
applications sharing a host/path/backend prefix still need distinct prefixes.
Duplicate module-level names and direct non-ASGI @cache calls are not
covered by this patch. Do not treat a cache key as an authorization boundary.

Install after publication

python -m pip uninstall -y fastapi-cache2
python -m pip install "fastapi-cache-stable[redis]==0.4.1"
python -m pip check

Do not run this before confirming that 0.4.1 exists on PyPI.

Published artifacts

  • PyPI 0.4.1
  • Wheel: fastapi_cache_stable-0.4.1-py3-none-any.whl — SHA-256 a68c770ebdd6dff06e7a6b282b71be1a60dc020b7d3f0b971c307a83489d708d
  • sdist: fastapi_cache_stable-0.4.1.tar.gz — SHA-256 e171db38e12b8a5b1815a5d781018b39d4af883be0d65ed01a6162cfeb0417af
  • TestPyPI workflow
  • Production PyPI workflow
  • Tag v0.4.1 targets ed1000bc09f7a17e3d93767e97d55eef77f5605b.

TestPyPI, PyPI and the workflow artifact are byte-identical. PyPI provenance binds the artifacts to stable, commit ed1000bc09f7a17e3d93767e97d55eef77f5605b and production run 44772219414. The final wheel passed clean installation, pip check, the factory/functools.wraps regression, and the real Redis compatibility suite. The pre-publication Dependabot delta found 21 unchanged accepted alerts and no new material findings.