On Sun, Nov 16, 2008 at 10:51 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Hello everyone,
>
> I'm trying to implement caching for my bilingual site. The problem is
> that once I enable caching and I change the language (via the example
> code in 
> http://docs.djangoproject.com/en/dev/topics/i18n/?from=olddocs#the-set-language-redirect-view
> ), the page does not change. The Content-Language header that the
> browser receives is indeed changed accordingly, but apparently the
> caching system is not aware of the change.
> I've set up my middleware as follows:
>
> MIDDLEWARE_CLASSES = (
>    'django.middleware.cache.UpdateCacheMiddleware',
>    'django.contrib.sessions.middleware.SessionMiddleware', # muss vor
> auth
>    'django.contrib.auth.middleware.AuthenticationMiddleware',
>    'django.middleware.locale.LocaleMiddleware',
>    'django.middleware.common.CommonMiddleware',
>    'django.middleware.cache.FetchFromCacheMiddleware',
> )
>
> I also tried per-site caching (disabling caching in the middleware),
> but did get the same results, even when I specified vary_on_headers
> ('Content-Language','Accept-Language').
>
> I have found a snippet (http://www.djangosnippets.org/snippets/443/)
> that might work, but I'm reluctant to use this hack and also rely on
> the deprecated CacheMiddleware.
>
> Any help and hints are appreciated!
>
> Thanks,
> Maik
>
> PS. relevant settings.py excerpt:
> CACHE_BACKEND = 'locmem:///'
> CACHE_MIDDLEWARE_SECONDS = 300
> CACHE_MIDDLEWARE_KEY_PREFIX = ''
> CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
>

The user's language preference might end being stored (and sent back) in
the django language preferences cookie or the session-related cookie.
So, to cover all the possible channels that preference could come in,
you will also need to indicate 'cookie', in the Vary header:

@vary_on_headers(''Accept-Language', 'Cookie')

See the following posts for related discussions:

http://groups.google.com/group/django-developers/browse_thread/thread/740f8d434e0660ff/5033945a4cdde102?hl=en&lnk=gst
http://groups.google.com/group/django-users/browse_thread/thread/256faa01c62b4f27/f4a382c540f47b5b?hl=en&lnk=gst

Regards,

--
 Ramiro Morales

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to