requests-cache travis-ci python

Transparent persistent cache for http://python-requests.org/ library

requests-cache

Requests-cache is a transparent persistent cache for requests_ (version >= 1.1.0) library.

.. _requests: http://python-requests.org/

.. image:: https://travis-ci.org/reclosedev/requests-cache.svg?branch=master :target: https://travis-ci.org/reclosedev/requests-cache

.. image:: https://coveralls.io/repos/reclosedev/requests-cache/badge.svg?branch=master&service=github :target: https://coveralls.io/github/reclosedev/requests-cache?branch=master

Usage example

Just write:

.. code-block:: python

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:

.. code-block:: python

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.

Note

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 <https://github.com/Lukasa/httpcache>_ and CacheControl <https://github.com/ionrock/cachecontrol>_.

Links

  • Documentation at readthedocs.org <https://requests-cache.readthedocs.io/>_

  • Source code and issue tracking at GitHub <https://github.com/reclosedev/requests-cache>_.

  • Working example at Real Python <https://realpython.com/blog/python/caching-external-api-requests>_.

Related Repositories

requests-cache

requests-cache

Transparent persistent cache for http://python-requests.org/ library ...

rack-worker

rack-worker

Rack middleware that implements the Worker Pattern to process generic GET requests in the background and only serve them from a cache. ...

superagent-no-cache

superagent-no-cache

Plugin for visionmedia/superagent that adds headers to all requests that prevents caching. ...

express-view-cache

express-view-cache

Unobtrusive solution to express framework - cache rendered page, without database requests and rendering. ...

cacheability

cacheability

Transparent client-side caching of HTTP requests (heap, file, memcache). Built-in support for RestClient. Built upon Rack::Cache. [will be replaced by http://github.com/crohr/rest-client-components] ...


Top Contributors

reclosedev rgant michaelbeaumont themiurgo YetAnotherNerd andrewkittredge mgax meowcoder adamchainz craigls dmr Garrett-R msabramo mjhea0 gwillem femtotrader

Releases

-   v0.4.12 zip tar
-   v0.4.11 zip tar
-   v0.4.10 zip tar
-   v0.4.9 zip tar
-   v0.4.8 zip tar
-   v0.4.7 zip tar
-   v0.4.6 zip tar
-   v0.4.5 zip tar
-   v0.4.4 zip tar
-   v0.4.3 zip tar
-   v0.4.2 zip tar
-   v0.4.1 zip tar
-   v0.4.0 zip tar
-   v0.3.0 zip tar
-   v0.2.1 zip tar
-   v0.2.0 zip tar
-   v0.1.3 zip tar
-   v0.1.2 zip tar
-   0.1.1 zip tar
-   0.1.0 zip tar