The DictCache is the default cache used when no other is
provided. It is a simple threadsafe dictionary. It doesn’t try to do
anything smart about deadlocks or forcing a busted cache, but it
should be reasonably safe to use.

Also, the DictCache does not transform the request or response
objects in anyway. Therefore it is unlikely you could persist the
entire cache to disk. The converse is that it should be very fast.

The FileCache supports a forever flag that disables deleting from
the cache. This can be helpful in debugging applications that make
many web requests that you don’t want to repeat. It also can be
helpful in testing. Here is an example of how to use it:

It should be noted that the FileCache uses pickle to store the
cached response. Prior to requests 2.1, requests.Response
objects were not ‘pickleable’ due to the use of IOBase base
classes in urllib3HTTPResponse objects. In CacheControl we work
around this by patching the Response objects with the appropriate
__getstate__ and __setstate__ methods when the requests version
doesn’t natively support Response pickling.