Skip to main content

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

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.12 (2016-02-12)

  • Increment version to satisfy PyPi

0.4.11 (2016-02-12)

  • Ability to force removal of expired entries

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

Release files for requests-cache-latest 0.4.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for requests-cache-latest 0.4.12
File Size Uploaded
requests-cache-latest-0.4.12.tar.gz 27.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for requests-cache-latest 0.4.12
File Interpreter ABI Platform
requests_cache_latest-0.4.12-py3-none-any.whl Python 3 none any Details

Total release size: 46.6 kB

Release files / requests-cache-latest-0.4.12.tar.gz

Download URL requests-cache-latest-0.4.12.tar.gz
Size 27.1 kB
Tags Source
SHA-256 checksum
How to use checksums
04ce221785429aa67e4920635e9f919ca0d5186c8a4c0931f23bd61944d10e52
BLAKE2b-256 checksum
How to use checksums
34304cdb141c2a7aeb29bcc6b72f34804e5f26ec5ed592c7ebeaddb635c88d26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / requests_cache_latest-0.4.12-py3-none-any.whl

Download URL requests_cache_latest-0.4.12-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35bdde6b7868b06d65230b7636dd6a31594fe280a1bf6de7abf01c8005dd4fe1
BLAKE2b-256 checksum
How to use checksums
2d54008258fa5700e23ec16a4a43345d17096ae454a07c138eba999a2c4ea178
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.4.12 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page