Opened 3 years ago

Closed 3 years ago

#32768 closed Bug (fixed)

An incorrect language is sometimes displayed - redirects adding a language code to a path can be inappropriate cached by HTTP caches

Reported by: Alex Hayward Owned by: nobody
Component: Internationalization Version: 3.1
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

We have a multi-lingual site using LocaleMiddleware. With a CDN and caching reverse proxy in use, the following sequence of events can happen:

LocaleMiddleware is issuing a redirect based on the detected language from the Accept-Language header or from the cookie chosen by settings.LANGUAGE_COOKIE_NAME but is not telling caches that it has used these headers.

Adding a Vary header fixes this.

Change History (4)

comment:1 by Alex Hayward, 3 years ago

Has patch: set

I've created a pull request, https://github.com/django/django/pull/14416

comment:2 by Carlton Gibson, 3 years ago

Triage Stage: UnreviewedAccepted

OK, I think this looks right. Let's take it for review to get other eyes on it. Thanks.

comment:3 by Carlton Gibson, 3 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by Carlton Gibson <carlton@…>, 3 years ago

Resolution: fixed
Status: newclosed

In eeed488a:

Fixed #32768 -- Added Vary header when redirecting to prefixed i18n pattern.

get_language_from_request() uses Accept-Language and/or Cookie to determine the
correct redirect. Upstream caches need the matching Vary header to cache the
result.

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