A cache provider for CacheControl using Django's caching mechanism.
Project description
cachecontrol-django
A cache provider for CacheControl using Django's caching mechanism.
Installation
pip install cachecontrol-django
Usage
import requests
from cachecontrol import CacheControl
from cachecontrol_django import DjangoCache
session = CacheControl(requests.session(), cache=DjangoCache())
session.get("https://www.glassesdirect.co.uk/")
Working Around Key Length Errors
If you see errors about key length (such as "MemcachedKeyLengthError: Key length is > 250"), you can ask DjangoCache to hash the keys it uses by specifying a key_hash_algorithm
:
long_url = 'https://www.glassesdirect.co.uk/?q=' + ('x' * 250)
session = CacheControl(
requests.session(),
cache=DjangoCache(key_hash_algorithm='sha512')
)
session.get(long_url)
Note that when hashing these keys, there is a very small chance of a hash collision causing a request for one URL to return the content of another.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for cachecontrol-django-1.0.dev0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b75b5e729c0b68839ea61826d6b9b15e714504c8cca2fb3faa0c0accb21a023 |
|
MD5 | 6603268a014ef4565de42e05a4619051 |
|
BLAKE2b-256 | bdfe895c078d15666de30a36c398ee25913ff787f467bea0aebcb35184605776 |