In the deployment checklist they included the hint on caching.
I wonder whether caching is always recommended in a Django project?
Or what are the thresholds/parameters to know whether to implement caching or not?
Currently my django project is only a minimal project with two forms and few static pages and pictures.
I don’t expect lot’s of traffic and I am planning to deploy it to Heroku or another free service for now - just to go through the deployment process once.
But in the long run the project as well as the traffic is meant to grow.
Is it recommended to implement caching right from the beginning or isn’t it a problem to implement it later (at a point where it might be more useful)?
Based on the source code of the SessionMiddleware
I assume that caching doesn’t work by default in production, because self.SessionStore = engine.SessionStore
always refers to the SESSION_ENGINE
in the settings (which is not active in the default Django project).
When I deactivate the SessionMiddleware
as described in How to use sessions, I get the following error:
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
?: (admin.E410) 'django.contrib.sessions.middleware.SessionMiddleware' must be in MIDDLEWARE in order to use the admin application.
HINT: Insert 'django.contrib.sessions.middleware.SessionMiddleware' before 'django.contrib.auth.middleware.AuthenticationMiddleware'.
In my understanding this means that I can decide to either deactivate the admin (somehow) or use activate the SessionMiddleware
.
If so, do I then also need to configure the CACHES
and the SESSION_ENGINE
?