{"id":13469319,"url":"https://github.com/requests-cache/requests-cache","last_synced_at":"2025-12-11T23:10:24.739Z","repository":{"id":2989753,"uuid":"4006131","full_name":"requests-cache/requests-cache","owner":"requests-cache","description":"Persistent HTTP cache for python requests","archived":false,"fork":false,"pushed_at":"2025-04-29T15:32:06.000Z","size":5145,"stargazers_count":1413,"open_issues_count":33,"forks_count":150,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-05-09T13:19:24.822Z","etag":null,"topics":["cache","dynamodb","http","mongodb","performance","redis","requests","sqlite","web","webscraping"],"latest_commit_sha":null,"homepage":"https://requests-cache.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/requests-cache.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-04-12T15:25:33.000Z","updated_at":"2025-05-09T05:53:20.000Z","dependencies_parsed_at":"2024-02-17T19:25:13.990Z","dependency_job_id":"b63c6cb1-1ca9-40b0-8ad0-8465f18b3990","html_url":"https://github.com/requests-cache/requests-cache","commit_stats":{"total_commits":1127,"total_committers":61,"mean_commits":"18.475409836065573","dds":"0.31322094055013305","last_synced_commit":"184d44c522858af4aed1c5721bf8b8653f40b7e1"},"previous_names":["reclosedev/requests-cache"],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/requests-cache%2Frequests-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/requests-cache%2Frequests-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/requests-cache%2Frequests-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/requests-cache%2Frequests-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/requests-cache","download_url":"https://codeload.github.com/requests-cache/requests-cache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253747995,"owners_count":21957846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","dynamodb","http","mongodb","performance","redis","requests","sqlite","web","webscraping"],"created_at":"2024-07-31T15:01:33.233Z","updated_at":"2025-12-11T23:10:24.687Z","avatar_url":"https://github.com/requests-cache.png","language":"Python","readme":"[![](docs/_static/requests-cache-logo-header.png)](https://requests-cache.readthedocs.io)\n\n[![Build](https://github.com/requests-cache/requests-cache/actions/workflows/build.yml/badge.svg)](https://github.com/requests-cache/requests-cache/actions)\n[![Codecov](https://codecov.io/gh/requests-cache/requests-cache/branch/main/graph/badge.svg?token=FnybzVWbt2)](https://codecov.io/gh/requests-cache/requests-cache)\n[![Documentation](https://img.shields.io/readthedocs/requests-cache/latest)](https://requests-cache.readthedocs.io/en/stable/)\n[![Code Shelter](https://www.codeshelter.co/static/badges/badge-flat.svg)](https://www.codeshelter.co/)\n\n[![PyPI](https://img.shields.io/pypi/v/requests-cache?color=blue)](https://pypi.org/project/requests-cache)\n[![Conda](https://img.shields.io/conda/vn/conda-forge/requests-cache?color=blue)](https://anaconda.org/conda-forge/requests-cache)\n[![PyPI - Python Versions](https://img.shields.io/pypi/pyversions/requests-cache)](https://pypi.org/project/requests-cache)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/requests-cache?color=blue)](https://pypi.org/project/requests-cache)\n\n## Summary\n**requests-cache** is a persistent HTTP cache that provides an easy way to get better\nperformance with the python [requests](https://requests.readthedocs.io/) library.\n\n\u003c!-- RTD-IGNORE --\u003e\nComplete project documentation can be found at [requests-cache.readthedocs.io](https://requests-cache.readthedocs.io).\n\u003c!-- END-RTD-IGNORE --\u003e\n\n## Features\n* 🍰 **Ease of use:** Keep using the `requests` library you're already familiar with. Add caching\n  with a [drop-in replacement](https://requests-cache.readthedocs.io/en/stable/user_guide/general.html#sessions)\n  for `requests.Session`, or\n  [install globally](https://requests-cache.readthedocs.io/en/stable/user_guide/general.html#patching)\n  to add transparent caching to all `requests` functions.\n* 🚀 **Performance:** Get sub-millisecond response times for cached responses. When they expire, you\n  still save time with\n  [conditional requests](https://requests-cache.readthedocs.io/en/stable/user_guide/headers.html#conditional-requests).\n* 💾 **Persistence:** Works with several\n  [storage backends](https://requests-cache.readthedocs.io/en/stable/user_guide/backends.html)\n  including SQLite, Redis, MongoDB, and DynamoDB; or save responses as plain JSON files, YAML,\n  and more\n* 🕗 **Expiration:** Use\n  [Cache-Control](https://requests-cache.readthedocs.io/en/stable/user_guide/headers.html#cache-control)\n  and other standard HTTP headers, define your own expiration schedule, keep your cache clutter-free\n  with backends that natively support TTL, or any combination of strategies\n* ⚙️ **Customization:** Works out of the box with zero config, but with a robust set of features for\n  configuring and extending the library to suit your needs\n* 🧩 **Compatibility:** Can be combined with other\n  [popular libraries based on requests](https://requests-cache.readthedocs.io/en/stable/user_guide/compatibility.html)\n\n## Quickstart\nFirst, install with pip:\n```bash\npip install requests-cache\n```\n\nThen, use [requests_cache.CachedSession](https://requests-cache.readthedocs.io/en/stable/modules/requests_cache.session.html)\nto make your requests. It behaves like a normal\n[requests.Session](https://requests.readthedocs.io/en/latest/user/advanced/#session-objects),\nbut with caching behavior.\n\nTo illustrate, we'll call an endpoint that adds a delay of 1 second, simulating a slow or\nrate-limited website.\n\n**This takes 1 minute:**\n```python\nimport requests\n\nsession = requests.Session()\nfor i in range(60):\n    session.get('https://httpbin.org/delay/1')\n```\n\n**This takes 1 second:**\n```python\nimport requests_cache\n\nsession = requests_cache.CachedSession('demo_cache')\nfor i in range(60):\n    session.get('https://httpbin.org/delay/1')\n```\n\nWith caching, the response will be fetched once, saved to `demo_cache.sqlite`, and subsequent\nrequests will return the cached response near-instantly.\n\n### Patching\nIf you don't want to manage a session object, or just want to quickly test it out in your\napplication without modifying any code, requests-cache can also be installed globally, and all\nrequests will be transparently cached:\n```python\nimport requests\nimport requests_cache\n\nrequests_cache.install_cache('demo_cache')\nrequests.get('https://httpbin.org/delay/1')\n```\n\n### Headers and Expiration\nBy default, requests-cache will keep cached responses indefinitely. In most cases, you will want to\nuse one of the two following strategies to balance cache freshness and performance:\n\n**Define exactly how long to keep responses:**\n\nUse the `expire_after` parameter to set a fixed expiration time for all new responses:\n```python\nfrom requests_cache import CachedSession\nfrom datetime import timedelta\n\n# Keep responses for 360 seconds\nsession = CachedSession('demo_cache', expire_after=360)\n\n# Or use timedelta objects to specify other units of time\nsession = CachedSession('demo_cache', expire_after=timedelta(hours=1))\n```\nSee [Expiration](https://requests-cache.readthedocs.io/en/stable/user_guide/expiration.html) for\nmore features and settings.\n\n**Use Cache-Control headers:**\n\nUse the `cache_control` parameter to enable automatic expiration based on `Cache-Control` and other\nstandard HTTP headers sent by the server:\n```python\nfrom requests_cache import CachedSession\n\nsession = CachedSession('demo_cache', cache_control=True)\n```\nSee [Cache Headers](https://requests-cache.readthedocs.io/en/stable/user_guide/headers.html)\nfor more details.\n\n\n### Settings\nThe default settings work well for most use cases, but there are plenty of ways to customize\ncaching behavior when needed. Here is a quick example of some of the options available:\n```python\nfrom datetime import timedelta\nfrom requests_cache import CachedSession\n\nsession = CachedSession(\n    'demo_cache',\n    use_cache_dir=True,                # Save files in the default user cache dir\n    cache_control=True,                # Use Cache-Control response headers for expiration, if available\n    expire_after=timedelta(days=1),    # Otherwise expire responses after one day\n    allowable_codes=[200, 400],        # Cache 400 responses as a solemn reminder of your failures\n    allowable_methods=['GET', 'POST'], # Cache whatever HTTP methods you want\n    ignored_parameters=['api_key'],    # Don't match this request param, and redact if from the cache\n    match_headers=['Accept-Language'], # Cache a different response per language\n    stale_if_error=True,               # In case of request errors, use stale cache data if possible\n)\n```\n\n\u003c!-- RTD-IGNORE --\u003e\n## Next Steps\nTo find out more about what you can do with requests-cache, see:\n\n* [User Guide](https://requests-cache.readthedocs.io/en/stable/user_guide.html)\n* [Examples](https://requests-cache.readthedocs.io/en/stable/examples.html)\n* [API Reference](https://requests-cache.readthedocs.io/en/stable/reference.html)\n* [Project Info](https://requests-cache.readthedocs.io/en/stable/project_info.html)\n\u003c!-- END-RTD-IGNORE --\u003e\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frequests-cache%2Frequests-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frequests-cache%2Frequests-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frequests-cache%2Frequests-cache/lists"}