It was written because httplib2’s better support for caching is often mitigated by its lack of threadsafety. The same is true of requests in terms of caching.
$ pip install CacheControl
Some of the included cache storage classes have external requirements. See Storing Cache Data for more info.
For the impatient, here is how to get started using CacheControl
import requests from cachecontrol import CacheControl sess = requests.session() cached_sess = CacheControl(sess) response = cached_sess.get('http://google.com')
This uses a threadsafe in memory dictionary for storage.
The tests are all in cachecontrol/tests and is runnable by py.test.
CacheControl is relatively new and maybe totally broken. I have some tests and it is a pretty direct port of httplib2 caching, which I’ve found to be very reliable. With that in mind, it hasn’t been used very extensively in a production environment to my knowledge.
If you give it a try, please let me know of any issues.