This simple Django utility allows you to utilize the 12factor inspired CACHE_URL environment variable to configure your Django application. It supports various cache backends like locmem, db, file, memcached, and redis. The library is actively maintained, with a recent release on January 24, 2026.
pip install django-cache-urlVerified import paths — ran on the pinned version, not inferred.
Configure your Django application's cache settings using the CACHE_URL environment variable, leveraging the `config` function. This example shows how to set up the default cache and a basic usage pattern.
For Redis-only, refer to Django's official documentation on Redis cache configuration. Otherwise, continue using `django-cache-url` for its intended purpose.
Ensure you install the corresponding Python package for the cache backend specified in your `CACHE_URL` (e.g., `pip install django-redis` for `redis://` URLs).
Implement explicit cache invalidation strategies (e.g., `cache.delete()`, `cache.clear()`) or leverage Django's `vary_on_headers` / `vary_on_cookie` decorators for views where content depends on request headers or user context.
Install the required package: `pip install django-redis` (or `pymemcache`, `django-pylibmc`, `uwsgicache` for other backends specified in your CACHE_URL).
Set the `CACHE_URL` environment variable (e.g., `export CACHE_URL="locmem://"`) or provide a default directly in `settings.py`: `CACHES = {'default': config(default='locmem://')}`.Review Django's caching documentation, especially regarding `vary_on_headers`, `vary_on_cookie`, and `key_prefix`. Ensure that dynamic content that relies on user state or query parameters is properly accounted for in cache key generation, or implement manual cache invalidation where appropriate.