Skip to main content

A cache provider for CacheControl using Django's caching mechanism.

Project description


A cache provider for CacheControl using Django's caching mechanism.

PyPI Build Status Code style: black


pip install cachecontrol-django


import requests
from cachecontrol import CacheControl
from cachecontrol_django import DjangoCache

session = CacheControl(requests.session(), cache=DjangoCache())

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 = '' + ('x' * 250)
session = CacheControl(

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

Download files

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

Files for cachecontrol-django, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size cachecontrol-django-1.0.0.tar.gz (2.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page