Eric
Eric

Reputation: 5091

How to start django session on demand?

when using django middleware, for every new visitor, a new session record or session file is created. this is fine except for websites where a large traffic part do not need session (exemple : a blog that is seen by many but written by only one).Is it possible to have the session middleware activated only for some urls so many I/Os will be saved ?

Upvotes: 0

Views: 689

Answers (1)

pennersr
pennersr

Reputation: 6511

This is actually not true. Sessions are lazily created, so only if data is put in the session a new record is created. Have a look here:

https://github.com/django/django/blob/master/django/contrib/sessions/middleware.py#L27

Upvotes: 1

Related Questions