requests-cache
A persistent cache for python requests
What it is and what it does
requests-cache wraps the requests library to transparently cache HTTP responses, eliminating redundant network calls. It acts as a drop-in replacement for requests.Session or can be installed globally to patch all requests functions without code changes. Responses are stored persistently across program runs using configurable backends (SQLite by default, or Redis, MongoDB, DynamoDB, JSON, YAML, etc.) and can expire based on fixed time intervals, HTTP Cache-Control headers, or custom schedules. The library is designed for minimal setup—zero configuration works out of the box—but offers extensive customization for matching strategies, conditional requests, and cache invalidation.
Typical use cases include reducing load on rate-limited APIs, speeding up repeated requests during development or testing, and improving performance in web scraping and data collection workflows. The package supports modern Python versions and is production-stable with no known vulnerabilities.
Use it for:
- Speed up repeated API calls during development or testing by caching responses locally instead of hitting the server each time.
- Reduce load on rate-limited APIs by reusing cached responses within expiration windows, avoiding unnecessary network requests.
- Build resilient scrapers that can serve stale cached data if a request fails, improving reliability in unstable network conditions.
- Cache responses with different expiration strategies per endpoint using Cache-Control headers or custom schedules.
- Store HTTP responses persistently across program runs in SQLite, Redis, or other backends for long-term reuse.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds persistent HTTP caching to the requests library, allowing cached responses to be reused across sessions with configurable expiration and multiple storage backends.
Yes. requests-cache is production-stable, actively maintained, has no known vulnerabilities, and adds caching to requests with minimal friction. Install it if you make repeated HTTP requests, need to respect rate limits, or want to speed up development workflows. The permissive BSD-2-Clause license poses no restrictions.
Install
requests-cache on PyPI
pip
pip install requests-cacheuv
uv add requests-cachepoetry
poetry add requests-cacheInstalling requests-cache
Before you install
Low install friction with a pure-Python wheel. Active maintenance with a recent release 42 days ago and ongoing commits. Depends on six common, stable packages: attrs, cattrs, platformdirs, requests, url-normalize, and urllib3.
License in practice
BSD-2-Clause is permissive; you can use this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install requests-cache
import requests_cache
session = requests_cache.CachedSession('demo_cache')
response = session.get('https://example.com/api')
Verify before relying
- Whether all storage backends (SQLite, Redis, MongoDB, DynamoDB) are included by default or require optional dependencies.
- Performance characteristics of conditional requests and how much time savings they provide relative to full cache misses.
- Compatibility scope with requests-based libraries beyond what the description mentions.
Package facts
| License | BSD-2-Clause (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — attrs, cattrs, platformdirs, requests, url-normalize, urllib3 |
| Maintenance | actively maintained — 42 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 21,000,366/month — #1,019 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: requests_cache-1.3.3-py3-none-any.whl
Keywords: cache, dynamodb, http, http-client, mongodb, performance, python-requests, redis, requests, sqlite, web, webscraping
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
aiohttp-client-cacheAdds transparent request caching to…
permissive · top 15,000 on PyPI
CacheControlCacheControl wraps requests sessions to…
permissive · top 1,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
BeakerBeaker provides session management and caching…
permissive · top 15,000 on PyPI
flexcacheCaches the results of expensive computations to…
permissive · top 5,000 on PyPI
httplib2httplib2 is an HTTP client library that handles…
permissive · top 1,000 on PyPI
py-memoizeCaching library for async Python applications…
permissive · top 15,000 on PyPI
cached-pathProvides a unified interface to access local…
permissive · top 15,000 on PyPI
hishelHishel is an HTTP caching library for Python…
permissive · top 5,000 on PyPI