Skip to main content

Persistent cache for requests library

Project description

requests-cache

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

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

Usage example

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.

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 and CacheControl.

History

0.4.10 (2015-04-28)

  • Better transactional handling in sqlite #50, thanks to @rgant

  • Compatibility with streaming in requests >= 2.6.x

0.4.9 (2015-01-17)

  • expire_after now also accepts timedelta, thanks to @femtotrader

  • Added Ability to include headers to cache key (include_get_headers option)

  • Added string representation for CachedSession

0.4.8 (2014-12-13)

  • Fix bug in reading cached streaming response

0.4.7 (2014-12-06)

  • Fix compatibility with Requests > 2.4.1 (json arg, response history)

0.4.6 (2014-10-13)

  • Monkey patch now uses class instead lambda (compatibility with rauth)

  • Normalize (sort) parameters passed as builtin dict

0.4.5 (2014-08-22)

  • Requests==2.3.0 compatibility, thanks to @gwillem

0.4.4 (2013-10-31)

  • Check for backend availability in install_cache(), not at the first request

  • Default storage fallbacks to memory if sqlite is not available

0.4.3 (2013-09-12)

  • Fix response.from_cache not set in hooks

0.4.2 (2013-08-25)

  • Fix UnpickleableError for gzip responses

0.4.1 (2013-08-19)

  • requests_cache.enabled() context manager

  • Compatibility with Requests 1.2.3 cookies handling

0.4.0 (2013-04-25)

  • Redis backend. Thanks to @michaelbeaumont

  • Fix for changes in Requests 1.2.0 hooks dispatching

0.3.0 (2013-02-24)

  • Support for Requests 1.x.x

  • CachedSession

  • Many backward incompatible changes

0.2.1 (2013-01-13)

  • Fix broken PyPi package

0.2.0 (2013-01-12)

  • Last backward compatible version for Requests 0.14.2

0.1.3 (2012-05-04)

  • Thread safety for default sqlite backend

  • Take into account the POST parameters when cache is configured with ‘POST’ in allowable_methods

0.1.2 (2012-05-02)

  • Reduce number of sqlite database write operations

  • fast_save option for sqlite backend

0.1.1 (2012-04-11)

  • Fix: restore responses from response.history

  • Internal refactoring (MemoryCache -> BaseCache, reduce_response and restore_response moved to BaseCache)

  • connection option for MongoCache

0.1.0 (2012-04-10)

  • initial PyPI release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

requests-cache-0.4.10.zip (42.8 kB view details)

Uploaded Source

requests-cache-0.4.10.tar.gz (28.0 kB view details)

Uploaded Source

Built Distribution

requests-cache-0.4.10.win32.exe (220.1 kB view details)

Uploaded Source

File details

Details for the file requests-cache-0.4.10.zip.

File metadata

File hashes

Hashes for requests-cache-0.4.10.zip
Algorithm Hash digest
SHA256 b0a35f8466fd6c3cd980e42e4ef53d5c35126cecef8a215743223bde5fd05cfa
MD5 5ab8184886659c5ae7bec4311db90118
BLAKE2b-256 a778d7f7ff83cefdf9e45aec372be52f5a76a8a7ee4412dad116491a703b6818

See more details on using hashes here.

File details

Details for the file requests-cache-0.4.10.tar.gz.

File metadata

File hashes

Hashes for requests-cache-0.4.10.tar.gz
Algorithm Hash digest
SHA256 671969d00719fa3e80476b128dc9232025926884d0110d4d235abdd9c3508fc0
MD5 4231368e27d63591280aafb8095a54cb
BLAKE2b-256 8bd71573609e3f9d6db0769e9a8df8c6aa0bfcf4b411cd50f33e177fcaeac7ed

See more details on using hashes here.

File details

Details for the file requests-cache-0.4.10.win32.exe.

File metadata

File hashes

Hashes for requests-cache-0.4.10.win32.exe
Algorithm Hash digest
SHA256 df64bc9581e46078922c81c261c638458d70565b030c32104bca7f004d1a2188
MD5 c6d4537c51e68dbc765c125e92e33b05
BLAKE2b-256 d13bb2317165a057ec4d6c30baf47fb25a8203783773c92073e5dc9c6bf3a0e6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page