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.

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 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.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.7.zip (40.5 kB view details)

Uploaded Source

requests-cache-0.4.7.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

requests-cache-0.4.7.win32.exe (218.1 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: requests-cache-0.4.7.zip
  • Upload date:
  • Size: 40.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for requests-cache-0.4.7.zip
Algorithm Hash digest
SHA256 20abbfa34e14ee1657db8951069f871f45b5b14f3fc9da51e18973f6c9be71e8
MD5 0f5b05da4056318b93344ebe2ef62cd9
BLAKE2b-256 254f294710b34c038fa2622b9ea78bb32439673e6c630947a3674684cab3696f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for requests-cache-0.4.7.tar.gz
Algorithm Hash digest
SHA256 49afcfa75fb0fc656d6c50103fbd39e48b77f265a5ead616164b079390963d8d
MD5 cb0c7eb8f913febf2971473986bbe1b7
BLAKE2b-256 50e149715ffba2cc26c30c15ac7d927d675eff705c6aee61abe74de9ece8daa1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for requests-cache-0.4.7.win32.exe
Algorithm Hash digest
SHA256 857d690f019c0ce705ad5a0a9f7bbd604f6faf5dd63a00003f00d9ac5b7317a5
MD5 2e190a5c93a14c0541ec2e82720ae986
BLAKE2b-256 31c1eddfc47e712efa36516f98b1ae6ac35891f604b99d7547e1aa9649bc7ebe

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