Use cached_db sessions by default#710
Conversation
fjsj
left a comment
There was a problem hiding this comment.
I think Redis is unnecessary here? cached_db means using the DB as cache, not Redis.
That cache layer does not have to be Redis specifically. It could also be DatabaseCache, Memcached, or https://docs.djangoproject.com/en/5.2/topics/http/sessions/#using-cached-sessions
|
|
Yep, I got confused, but what I wanted was what we had in other simple projects by using locmem. I see docs now don't recommend locmem, as you quoted: "The local-memory cache backend doesn’t retain data long enough to be a good choice, and it’ll be faster to use file or database sessions directly instead of sending everything through the file or database cache backends.". So I guess the best is to drop this. In general having Redis as a failure-point to get some little performance gain is not the best option for most projects. Thanks anyway for the PR! Dropping it. |
Description
This PR improves the backend session setup by configuring Django to use Redis as the default cache and cached_db
as the session engine, bringing the application closer to its intended runtime behavior. It also improves
development visibility by enabling more detailed Gunicorn access logs, making it easier to inspect requests and
debug backend behavior locally. Since the new session setup introduces a cache dependency, the test configuration
was updated to use an in-memory cache to keep tests isolated and independent from Redis.
Motivation and Context
The changes in this PR are grouped because they all support the same backend infrastructure improvement:
inspect.
Overall, this brings development and runtime behavior closer together while keeping the test environment
lightweight and deterministic.
Screenshots (if appropriate):
N/A
Steps to reproduce (if appropriate):
Types of changes
Checklist:
Closes #560