(filesystem)=
This backend stores responses in files on the local filesystem, with one file per response.
This backend is useful if you would like to use your cached response data outside of requests-cache, for example:
Initialize with a {py:class}.FileCache instance:
>>> from requests_cache import CachedSession, FileCache >>> session = CachedSession(backend=FileCache())
Or by alias:
>>> session = CachedSession(backend='filesystem')
By default, responses are saved as pickle files. If you want to save responses in a human-readable format, you can use one of the other available {ref}serializers. For example, to save responses as JSON files:
>>> session = CachedSession('~/http_cache', backend='filesystem', serializer='json') >>> session.get('https://httpbin.org/get') >>> print(list(session.cache.paths())) > ['/home/user/http_cache/4dc151d95200ec.json']
Or as YAML (requires pyyaml):
>>> session = CachedSession('~/http_cache', backend='filesystem', serializer='yaml') >>> session.get('https://httpbin.org/get') >>> print(list(session.cache.paths())) > ['/home/user/http_cache/4dc151d95200ec.yaml']
files for general info on specifying cache paths<cache_name>/<cache_key><cache_name>/redirects.sqlite.FileCache.paths to get a list of all cached response paths