Requests-cache is a transparent persistent cache for the requests library (version 2+).
Just write:
import requests
import requests_cache
requests_cache.install_cache('demo_cache')
And all responses with headers and cookies will be transparently cached to demo_cache.sqlite database. For example, following code will take only 1-2 seconds instead of 10, and will run instantly on next launch:
for i in range(10):
requests.get('http://httpbin.org/delay/1')
It can be useful when you are creating some simple data scraper with constantly changing parsing logic or data format, and don't want to redownload pages or write complex error handling and persistence.
requests-cache
ignores all cache headers, it just caches the data for the
time you specify.
If you need library which knows how to use HTTP headers and status codes, take a look at httpcache and CacheControl.
While the original author no longer has time to work on requests-cache (see note here), one or more maintainers are available via Code Shelter to help keep this project going.
Maintenance will mainly focus on bugfixes, security and compatibility updates, etc. If there is a new feature you would like to see, the best way to make that happen is to submit a PR for it!
If you have an issue or PR that hasn't recieved a response in a timely manner, or if you want to discuss ideas about the project in general, please reach out on the Code Shelter chat server, under projects/requests-cache.
- Documentation at readthedocs
- Source code and issue tracking at GitHub.
- Working example at Real Python.