fastapi-cache2
Cache for FastAPI
Decision gist · record as of 2026-08-14
Yes, with conditions. The package is straightforward to integrate and widely used, but its aging maintenance status (751 days since last release) means you should verify compatibility with your FastAPI and Python versions before adopting it. No known vulnerabilities. Choose this if you need transparent endpoint caching with multiple backend options; avoid if you require active maintenance or cutting-edge feature updates.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a running cache backend (Redis, Memcached, or DynamoDB) or uses in-memory storage; backend client configuration depends on chosen backend.
- Low install friction with five runtime dependencies.
- Maintenance status is aging—last release was 2024-07-24 and the repository has not been updated for 751 days, though it remains active and unarchived with 1866 stars.
License · maintenance · safety
Apache-2.0 (permissive) — Licensed under Apache-2.0 (permissive), allowing commercial use, modification, and distribution with minimal restrictions.
last release 2024-07-24 (751 days) · last repo commit 2025-06-30 · 1,866 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,050,069 downloads/mo, #4,443 on PyPI
Alternatives
Verify before relying
pip install fastapi-cache2
from fastapi_cache import FastAPICache
from fastapi_cache.decorator import cache
FastAPICache.init(backend, prefix="fastapi-cache")
@app.get("/")
@cache(expire=60)
async def index():
return dict(hello="world")- Whether the aging maintenance status (751 days since last release) affects compatibility with recent FastAPI or Python versions.
- Performance characteristics and memory overhead of the in-memory backend for production workloads.
- Specific backend setup requirements and client library versions for Redis, Memcached, and DynamoDB.
What it is and what it does
fastapi-cache2 is a caching layer for FastAPI applications that transparently stores and retrieves endpoint and function results. It wraps your route handlers with a @cache decorator that automatically manages cache expiration, key generation, and backend storage. The package supports multiple backends—Redis, Memcached, DynamoDB, and in-memory—so you can choose the right storage for your deployment.
The decorator integrates with FastAPI's dependency injection to handle HTTP cache semantics: it can set ETag and Cache-Control headers, return 304 Not Modified responses for conditional requests, and track cache hits and misses. You can customize cache behavior per endpoint with parameters like expiration time, namespace, and key-building strategy, or implement custom coders to handle non-JSON data types like Pydantic models and dataclasses.
Use it for
- Cache API responses with automatic expiration to reduce database queries and improve endpoint latency.
- Store results of expensive computations across multiple application instances using a shared backend.
- Serve cached responses with proper HTTP cache headers and conditional request support for browser caching.
- Cache function results in memory for single-instance deployments or testing without external dependencies.
- Implement custom cache keys based on request method, URL, and query parameters instead of function arguments.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, with conditions.
The package is straightforward to integrate and widely used, but its aging maintenance status (751 days since last release) means you should verify compatibility with your FastAPI and Python versions before adopting it. No known vulnerabilities. Choose this if you need transparent endpoint caching with multiple backend options; avoid if you require active maintenance or cutting-edge feature updates.
Install
fastapi-cache2 on PyPI
Before you install
Low install friction with five runtime dependencies. Maintenance status is aging—last release was 2024-07-24 and the repository has not been updated for 751 days, though it remains active and unarchived with 1866 stars.
Requires a running cache backend (Redis, Memcached, or DynamoDB) or uses in-memory storage; backend client configuration depends on chosen backend.
License in practice
Licensed under Apache-2.0 (permissive), allowing commercial use, modification, and distribution with minimal restrictions.
Quickstart
pip install fastapi-cache2
from fastapi_cache import FastAPICache
from fastapi_cache.decorator import cache
FastAPICache.init(backend, prefix="fastapi-cache")
@app.get("/")
@cache(expire=60)
async def index():
return dict(hello="world")
Verify before relying
- Whether the aging maintenance status (751 days since last release) affects compatibility with recent FastAPI or Python versions.
- Performance characteristics and memory overhead of the in-memory backend for production workloads.
- Specific backend setup requirements and client library versions for Redis, Memcached, and DynamoDB.
Package facts
| License | Apache-2.0 permissive |
| Python support | Supports the current Python release <4.0,>=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 5 packagesfastapiimportlib-metadatapendulumtyping-extensionsuvicorn |
| Maintenance | Aging 751 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,050,069 / month, #4,443 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: fastapi_cache2-0.2.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “fastapi caching decorator”
- fastapi-cache2Caches FastAPI endpoint and function results with support for Redis,…
- fastapi-decoratorsConverts functions into FastAPI-compatible decorators that can inject…
- fastapi-utilitiesProvides reusable utilities for FastAPI applications including…
Give your agent the search over MCP, or paste the wish link into any chat.
More Dynamic Content packages
MarkupSafe provides a text object that escapes special characters so untrusted strings can be safely embedded in HTML and XML without injection attacks.
Jinja2 is a templating engine that renders dynamic content by combining templates with Python-like syntax and data, supporting template inheritance, macros, autoescaping, and sandboxed execution.
Soupsieve is a CSS selector library designed to work with Beautiful Soup 4 to select, match, and filter HTML and XML elements using modern CSS selectors from CSS level 1 through CSS level 4 specifications.
Install it if you use Beautiful Soup for HTML or XML parsing and want modern CSS selector support.
Werkzeug is a WSGI utility library providing request/response objects, URL routing, an interactive debugger, HTTP utilities, and a development server for building web applications.
Flask is a lightweight WSGI web application framework for building web applications in Python, from simple single-page sites to complex multi-route applications.
Mako compiles Python-embedded templates into Python modules for fast rendering, supporting layout inheritance, custom functions, and direct Python expressions within template syntax.
See also cachelib · cashews · aiohttp-client-cache · django-cache-url · requests-cache · fastapi-lifespan-manager · fastapi-utilities · aiocache · fastapi-decorators · fastapi-versioning