skillfed

aiohttp-client-cache

Persistent cache for aiohttp requests

aiohttp-client-cache v0.14.3 222.2K downloads/30d#9,268 on PyPI154
Permissive license MIT License Active released

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-cache

uv

uv add aiohttp-client-cache

poetry

poetry add aiohttp-client-cache

Installing 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

Development Status :: 4 - BetaFramework :: AsyncIOFramework :: aiohttpIntended Audience :: DevelopersTopic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

aiohttp request cachingasync http cachepersistent http response cacheaiohttp session cachingredis mongodb cache backendasyncio http memoizationaiohttp performance optimization
async-httpcachingpersistence

More Python Modules packages