I am starting to get to understand the problem. I hope. I did the
following test.
My current middleware settings:
MIDDLEWARE_CLASSES = (
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.gzip.GZipMiddleware",
"django.middleware.cache.CacheMiddleware",
"django.middleware.locale.LocaleMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.middleware.common.CommonMiddleware",
"django.contrib.csrf.middleware.CsrfMiddleware",
"django.middleware.doc.XViewMiddleware",
"django.middleware.http.ConditionalGetMiddleware",
#"django.contrib.flatpages.middleware.FlatpageFallbackMiddleware",
)
In Firefox I have three languages enables: nl, en-us and en. I hit a
page and I get two cached files. One cache_header and one cache_page.
When I change my language setting in my browser and delete for example
the en language and hit the same page again I get a second cache_page!
Great! If I switch the remaining nl and en-us settings I get a third
cache_page. So, vary on Accept-language is working. I even get the
correct language shown on the pages. So, something is working even with
caching enabled.
I am getting closer to the problem.
I use the set_language redirect view for the user to be able to switch
between languages. This is still NOT working! From the documentation:
"The view expects to be called via the GET method, with a language
parameter set in the query string. If session support is enabled, the
view saves the language choice in the user's session. Otherwise, it
saves the language choice in a django_language cookie."
I have session enabled. So, the cache should use the vary on cookie.
Even if I do not use sessions the language choice is stored in a cookie
and thus the cache should vary on cookie.
Apparently this is not working!
Switching the order of the middelware to:
MIDDLEWARE_CLASSES = (
"django.middleware.cache.CacheMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.gzip.GZipMiddleware",
"django.middleware.locale.LocaleMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.middleware.common.CommonMiddleware",
"django.contrib.csrf.middleware.CsrfMiddleware",
"django.middleware.doc.XViewMiddleware",
"django.middleware.http.ConditionalGetMiddleware",
#"django.contrib.flatpages.middleware.FlatpageFallbackMiddleware",
)
Then the cache_header files show that the cache is also varying on
cookie. I can switch once between Dutch and English using the set
language redirect view. And I got two cache_pages for each page. But, I
can only switch once!
I am almost there. I think. But, it still is not working! Why?
On 28 dec, 11:19, "Beegee" <[EMAIL PROTECTED]> wrote:
Jeremy,
Thanks for the explanation. I am using mod_python. I will check if my
browser are sending Accept-Language. But, I suspect they do. Because,
whenever caching is disabled swithing between languages works perfect.
If I change for example the language settings in my browser and make
for example Dutch my preferred language then the websitewww.localpoint.nlis
rendered in Dutch. And if I make English my
preferred language my website is rendered in English. So, the language
settings in my browsers (FF and IE) are correctly handled by the
Django.
But whenever I activate caching language switching is not working
anymore.
Berry
On Dec 26, 3:28 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 12/26/06,Beegee<[EMAIL PROTECTED]> wrote:
> ...
> > > Perhaps there is a bug in locale.py. Should:
> > > patch_vary_headers(response, ('Accept-Language',))
> > > perhaps be:
> > > patch_vary_headers(response, ('Content-Language',))
> ...
> > I made the change mentioned above. But, it simply does NOT work!
> > Whenever I enable global caching I can NOT switch between languages
> > anymore. Only one page is saved in the cache!I apologize for mixing you up. The
vary header is "the set of
> request-header fields that fully determines, while the response is
> fresh, whether a cache is permitted to use the response to reply to a
> subsequent request without revalidation". (rfc2616, 14.44 Vary)
> Which is to say, Accept-Language is the appropriate value to place in
> the Vary header, since that is the request-header field we're
> interested in varying on, *not* Content-Language.
> Even so, have you verified that your browsers are sending
> Accept-Language as expected?
> Second, are you using mod_python or wsgi? I'm asking because the
> headers django.util.cache.learn_cache_key depends on are expected to
> be munged into request.META on round-trip. I do see that munging
> occurring in django.core.handlers.modpython, but not in
> django.core.handlers.wsgi.
> I haven't tested that here-- I'm not set up for trunk testing or i18n,
> but if you're using wsgi, this may be your bug...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---