aiohttp-client-cache
Persistent cache for aiohttp requests
What it is and what it does
aiohttp-client-cache wraps aiohttp.ClientSession to transparently cache HTTP responses, avoiding redundant network requests for identical URLs. It is designed as a drop-in replacement: you instantiate CachedSession with a cache backend instead of ClientSession, and responses are automatically stored and reused according to your configuration.
The package supports multiple storage backends—SQLite (file-based, no external service), Redis, MongoDB, DynamoDB, and DragonflyDB—so you can choose persistence that fits your deployment model. You configure cache expiration per-URL pattern, HTTP method, status code, and request headers; responses can be set to never expire, expire after a fixed duration, or follow HTTP cache headers. It is built on the same principles as requests-cache but adapted for async/await workflows.
Use it for:
- Speed up web scraping or API polling by caching responses and avoiding rate limits or slow servers.
- Reduce load on external APIs during development and testing by replaying cached responses.
- Build resilient microservices that can serve stale cached responses when a backend is temporarily unavailable.
- Cache responses from slow or rate-limited third-party APIs to improve application latency.
- Persist HTTP responses across application restarts using SQLite or a shared Redis instance.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds transparent request caching to aiohttp.ClientSession, storing HTTP responses persistently across multiple backends (SQLite, Redis, MongoDB, DynamoDB, DragonflyDB) with configurable expiration and filtering.
Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and solves a genuine problem for async Python applications that make repeated HTTP requests. It is particularly valuable if you are already using aiohttp and need transparent caching without rewriting your session logic. The permissive MIT license and support for multiple backends make it flexible for both development and production use.
Install
aiohttp-client-cache on PyPI
pip
pip install aiohttp-client-cacheuv
uv add aiohttp-client-cachepoetry
poetry add aiohttp-client-cacheInstalling aiohttp-client-cache
Before you install
Low friction: pure Python wheel with five straightforward dependencies (aiohttp, attrs, itsdangerous, typing-extensions, url-normalize). Actively maintained as of 2026-01-07, with recent commits and no known vulnerabilities.
License in practice
MIT License permits commercial and private use with minimal restrictions; you must include a copy of the license in distributions.
Quickstart
pip install aiohttp-client-cache
from aiohttp_client_cache import CachedSession, SQLiteBackend
async with CachedSession(cache=SQLiteBackend('demo_cache')) as session:
await session.get('http://example.com')
Requires Python 3.9 or later; backend-specific optional dependencies (e.g., redis, pymongo) needed only if using those storage backends.
Verify before relying
- Whether all five runtime dependencies are truly required or if some are optional for specific backends.
- Performance overhead of cache lookup compared to uncached aiohttp requests.
- Concurrency behavior and thread-safety guarantees when multiple tasks access the same cache simultaneously.
Package facts
| License | MIT License (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — aiohttp, attrs, itsdangerous, typing-extensions, url-normalize |
| Maintenance | actively maintained — 219 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 222,186/month — #9,268 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: aiohttp_client_cache-0.14.3-py3-none-any.whl
Keywords: aiohttp, async, asyncio, cache, cache-backends, client, dragonflydb, dynamodb, http, mongodb, persistence, redis, requests, sqlite
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
requests-cacheAdds persistent HTTP caching to the requests…
permissive · top 5,000 on PyPI
fastapi-cache2Caches FastAPI endpoint and function results…
permissive · top 5,000 on PyPI
acachecontrolAdds HTTP caching to aiohttp requests by…
permissive · top 15,000 on PyPI
cachelibCacheLib provides a unified API for interacting…
permissive · top 5,000 on PyPI
aioresponsesMocks HTTP requests made by aiohttp's…
permissive · top 5,000 on PyPI
aiohttp-asyncmdnsresolverProvides an async resolver for aiohttp that…
permissive · top 15,000 on PyPI
aiodataloaderBatches and caches concurrent data requests in…
permissive · top 5,000 on PyPI
py-key-value-aioProvides an async-only, pluggable key-value…
permissive · top 1,000 on PyPI
cachierCachier is a decorator that adds persistent,…
permissive · top 15,000 on PyPI
hishelHishel is an HTTP caching library for Python…
permissive · top 5,000 on PyPI