Friday, November 4, 2011

Re: I18N and caching: page don't change language until I press F5 in browser

Hallöchen!

Salvatore Iovene writes:

> On Friday, November 4, 2011 5:31:46 PM UTC+2, Salvatore Iovene wrote:
>>
>> if hasattr(request, 'session'):
>> request.session['django_language'] = lang
>> else:
>> response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang)
>>
>
> I have solved my problem by setting the cookie unconditionally (i.e.
> outside of that else-statement). I copied that code from
> django.views.i18n.set_language. I wonder if that's a bug.

Strange. I had the very same problem, but I identified the
browser's internal caching heuristics as the problem. If there are
no explicit caching headers in the response, the browser guesses.
Sending e.g. "Expires: ..." so that the page expires immediately
solved the problem.

(By the way, I didn't send those headers eventually. The browser's
heuristics make the site faster in other cases, and users switch
language only seldomly.)

Tschö,
Torsten.

--
Torsten Bronger Jabber ID: torsten.bronger@jabber.rwth-aachen.de
or http://bronger-jmp.appspot.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate