Fixes #17866: Vary: Accept-Language header when language prefix used #796

Merged
merged 1 commit into from Feb 23, 2013

Projects

None yet

2 participants

@ambv
Contributor
ambv commented Feb 23, 2013

Tests pass on 2.7 and 3.3.

Remarks:

  • we cannot restrict including "Accept-Language" to only the case when it was used in page rendering. The language might be taken from the session or a client cookie. In that case the user gets that specific language but it doesn't mean the server doesn't vary content depending on Accept-Language (e.g. if the session would be empty and the cookie not set). Such a thing would break caching proxies. Taking that into account, I leave out "Vary: Accept-Language" on i18n_patterns URLs only.
  • the patch reuses supported languages across requests to speed up computation, trans_null had to learn the supported``argument to``get_language_from_path()``(already intrans_real`).
  • now LocaleMiddleware.is_language_prefix_pattern_used() would be computed in every response so I moved this computation to __init__ since it's not going to change between restarts
  • on a similar note, django.utils.translation.trans_real.check_for_language is needlessly computed for every get_language_from_path(). It won't change between restarts of the application, shouldn't we memoize it?
@HonzaKral HonzaKral merged commit c2a0451 into django:master Feb 23, 2013
@ambv ambv deleted the unknown repository branch Feb 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment