Opened 14 years ago

Closed 6 years ago

Last modified 4 years ago

#15902 closed Cleanup/optimization (fixed)

Store the current language in a cookie rather than the session

Reported by: msiedlarek Owned by: msiedlarek
Component: Internationalization Version: dev
Severity: Normal Keywords: language i18n session cookie
Cc: msiedlarek, raymond.penners@…, vlastimil.zima@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Luke Plant)

Related discussion

http://groups.google.com/d/topic/django-developers/8THmJSioj4U/discussion

Problem summary

The problem is that even for non-logged users their language is stored in session (if it's supported or in the cookie otherwise). That creates a session for every client, which makes serving static (ofc I mean static, but not media) content through an upstream cache (such as Squid) really inefficient. I suppose selected language is not that secret to protect it by storing in session, and cookie is just ok. For cookie-varying cache it's a huge difference.

Solution proposal

There is a setting named LANGUAGE_COOKIE_NAME which never gets used if you use session based cookies. The file cookie is just never saved. But if there were an option to save data in the session and also save the LANGUAGE_COOKIE as a file separately - then it would also persist after logout and solve the issue with languages after the session gets destroyed.

(...)

I would propose to have the set_language() view with options to set it as a file based cookie or a session.

(...)

It would allow the language file based cookie to have a very long expire date and the session would still be usable for storing secure data.

Change History (13)

comment:1 by Luke Plant, 14 years ago

Description: modified (diff)
Triage Stage: UnreviewedAccepted

This is proposing the same thing as #12794, but for a different reason.

#13217 is related, but the solution proposed here was not proposed there, and doesn't have the same issues that caused the WONTFIX on that ticket. This change would help that problem if the cache is able to cache by language cookie.

I'm not in favour of yet another setting if we can avoid it - we need to know if there are any downsides to always storing in the cookie rather than the session. If not, we always store in the cookie. Since we've documented the current behaviour, we may however need a deprecation path involving a setting.

comment:2 by msiedlarek, 14 years ago

I propose we discuss on this strictly on django-developers to avoid general mess and redundancy.

http://groups.google.com/d/topic/django-developers/8THmJSioj4U/discussion

comment:3 by raymond.penners@…, 14 years ago

Cc: raymond.penners@… added

comment:4 by Vlastimil Zíma, 13 years ago

Cc: vlastimil.zima@… added
UI/UX: unset

comment:5 by Claude Paroz, 8 years ago

Has patch: set
Version: 1.3master

This PR tries to depart from storing the user language in the session.

comment:6 by Tim Graham, 8 years ago

Patch needs improvement: set

comment:7 by Claude Paroz, 7 years ago

This PR just adds the language in a cookie unconditionally, so we can later deprecate and remove language in the session with minimal backwards incompatibility (this was discussed on the previous PR).

Last edited 7 years ago by Tim Graham (previous) (diff)

comment:8 by Tim Graham <timograham@…>, 7 years ago

In b3cd9fb1:

Refs #15902 -- Made set_language() view always set the current language in a cookie.

The plan is to later deprecate/remove storing the language in the session.

comment:9 by Claude Paroz, 6 years ago

Patch needs improvement: unset

I updated the pull request (https://github.com/django/django/pull/10875). I was not sure if we meant adding a deprecation in 2.2, but I guess it's late now.

comment:10 by Tim Graham, 6 years ago

Summary: Storing current language in session/cookieStore the current language in a cookie rather than the session
Type: New featureCleanup/optimization

comment:11 by Tim Graham <timograham@…>, 6 years ago

In a8e2a9ba:

Refs #15902 -- Deprecated storing user's language in the session.

comment:12 by Tim Graham, 6 years ago

Resolution: fixed
Status: newclosed

comment:13 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In d134b0b9:

Refs #15902 -- Stopped set_language() storing user's language in the session.

Per deprecation timeline.

Note: See TracTickets for help on using tickets.
Back to Top