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 https://coveralls.io/repos/reclosedev/requests-cache/badge.svg?branch=master&service=github Code Shelter

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.5.2 (2019-08-14)

  • Fix DeprecationWarning from collections #140

0.5.1 (2019-08-13)

  • Remove Python 2.6 Testing from travis #133

  • Fix DeprecationWarning from collections #131

  • vacuum the sqlite database after clearing a table #134

  • Fix handling of unpickle errors #128

0.5.0 (2019-04-18)

Project is now added to https://www.codeshelter.co/

  • Add gridfs support, thanks to @chengguangnan

  • Add dynamodb support, thanks to @ar90n

  • Add response filter #104, thanks to @christopher-dG

  • Fix bulk_commit #78

  • Fix remove_expired_responses missed in __init__.py #93

  • Fix deprecation warnings #122, thanks to mbarkhau

0.4.13 (2016-12-23)

  • Support PyMongo3, thanks to @craigls #72

  • Fix streaming releate issue #68

0.4.12 (2016-03-19)

  • Fix ability to pass backend instance in install_cache #61

0.4.11 (2016-03-07)

  • ignore_parameters feature, thanks to @themiurgo and @YetAnotherNerd (#52, #55)

  • More informative message for missing backend dependencies, thanks to @Garrett-R (#60)

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 Distribution

requests-cache-0.5.2.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

requests_cache-0.5.2-py2.py3-none-any.whl (22.4 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: requests-cache-0.5.2.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/2.7.15+

File hashes

Hashes for requests-cache-0.5.2.tar.gz
Algorithm Hash digest
SHA256 813023269686045f8e01e2289cc1e7e9ae5ab22ddd1e2849a9093ab3ab7270eb
MD5 f2fc5a03c5c06496d9d360b1e54f6ea0
BLAKE2b-256 0cd4bdc22aad6979ceeea2638297f213108aeb5e25c7b103fa02e4acbe43992e

See more details on using hashes here.

File details

Details for the file requests_cache-0.5.2-py2.py3-none-any.whl.

File metadata

  • Download URL: requests_cache-0.5.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/2.7.15+

File hashes

Hashes for requests_cache-0.5.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 81e13559baee64677a7d73b85498a5a8f0639e204517b5d05ff378e44a57831a
MD5 c652fabe5009a3dd8ea7249ec6e5a180
BLAKE2b-256 7f559b1c40eb83c16d8fc79c5f6c2ffade04208b080670fbfc35e0a5effb5a92

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