My site serves pages that are almost static and there are no users with logins etc.
I want to completely disable sessions for performance reasons (so django won't access the DB to get the session on every request).
I removed django.contrib.sessions
from INSTALLED_APPS, is there anything else I need to do?
You should locate articles how to set up sessions in django and remove everything from settings.py according to such article. Here is it:
Although this should already be setup and working correctly, it’s nevertheless good practice to learn which Django modules provide which functionality. In the case of sessions, Django provides middleware that implements session functionality.
To check that everything is in order, open your Django project’s settings.py file. Within the file, locate the MIDDLEWARE_CLASSES tuple. You should find the django.contrib.sessions.middleware.SessionMiddleware module listed as a string in the tuple - if you don’t, add it to the tuple now. It is the SessionMiddleware middleware which enables the creation of unique sessionid cookies.
The SessionMiddleware is designed to work flexibly with different ways to store session information. There are many approaches that can be taken - you could store everything in a file, in a database, or even in a cache. The most straightforward approach is to use the django.contrib.sessions application to store session information in a Django model/database (specifically, the model django.contrib.sessions.models.Session). To use this approach, you’ll also need to make sure that django.contrib.sessions is in the INSTALLED_APPS tuple of your Django project’s settings.py file. If you add the application now, you’ll need to synchronise your database using the python manage.py syncdb command to add the new tables to your database.
So it seems that you should remove middleware too. Maybe it's not necessary, but if you're using static application, then you it's not that bad to remove everything according to the sessions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With