skillfed

requests-cache

A persistent cache for python requests

requests-cache v1.3.3 21.0M downloads/30d#1,019 on PyPI1,502
Permissive license BSD-2-Clause Active released

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

uv

uv add requests-cache

poetry

poetry add requests-cache

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

http request cachingpersistent requests cachecache http responsesrequests library cachingreduce http requestsconditional request headerscache storage backends
http-cachingperformance-optimizationweb-scraping

More Python Modules packages