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:
- Fetch https://example.com/some-page/ with Accept-Language header 'de-DE,de;q=0.9'. A redirect to https://example.com/de/some-page/ is returned.
- Fetch it again with Accept-Language header 'fr-FR,fr;q=0.9'. The cached redirect is returned by HTTP caches and the German page is displayed instead of the French one.
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 , 3 years ago
Has patch: | set |
---|
comment:2 by , 3 years ago
Triage Stage: | Unreviewed → Accepted |
---|
OK, I think this looks right. Let's take it for review to get other eyes on it. Thanks.
comment:3 by , 3 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
I've created a pull request, https://github.com/django/django/pull/14416