1.5 KiB
Caching
EUSRR uses Redis for Django cache and a separate Redis database for Channels and Celery.
Backend configuration
backend/eusrr_backend/settings.py configures the default cache as:
- URL:
redis://<REDIS_HOST>:<REDIS_PORT>/1; - key prefix:
eusrr_cache; - default TTL: 300 seconds.
The Channels layer uses Redis database 0. Celery URLs are configured separately
through CELERY_BROKER_URL and CELERY_RESULT_BACKEND.
CacheControlMiddleware adds Cache-Control: private, max-age=60 to successful
HTML GET responses unless a view already set the header. API, admin, static and
media paths are excluded.
Per-user page cache
common.cache_decorators.cache_page_per_user caches successful authenticated
GET responses by user, path and sorted query string and exposes X-Cache as
HIT or MISS. invalidate_cache_pattern removes keys using Redis pattern
deletion when supported.
Before applying the decorator, verify that the response is user-specific and that every write path invalidates all affected keys. Do not cache permission decisions or responses containing another user's data under a shared key.
Diagnostics
redis-cli -n 1 scan 0 match 'eusrr_cache:*' count 100
Use cache.clear() from Django shell for a development reset. Do not use
FLUSHDB in a shared Redis instance.
Frontend request state is independent from Django cache. The Next.js application
uses its own component/context state; the legacy Django UI still contains a
static/js/managers/dataManager.js cache.