Don't consider Accept-Language when generating a cache key
|Reported by:||choongmin@…||Owned by:||ambv|
|Component:||Core (Cache system)||Version:||master|
|Severity:||Normal||Keywords:||cache vary i18n|
|Has patch:||yes||Needs documentation:||yes|
|Needs tests:||yes||Patch needs improvement:||yes|
Currently, Django makes different cache keys for different Accept-Language headers. But different Accept-Language headers may be resolved into the same language. For example, see the following Accept-Language headers collected in my site for last 30 minutes:
- ko, en
- ko-KR, en-US
It makes the cache system inefficient for multilingual sites. Since there is utils.cache._i18n_cache_key_suffix, it is unnecessary and redundant to include Accept-Language headers in a cache key. We should ignore them in utils.cache.learn_cache_key.
Note that not adding "Vary: Accept-Language" from the first place in middleware.locale.process_response is not a good solution because of proxy servers.
The attached patch removes Accept-Language from headerlist before generating a cache key.
If the patch is rejected, users like me should at least be able to ignore them.
Change History (6)
Changed 4 years ago by choongmin@…
comment:1 Changed 4 years ago by jezdez
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:2 Changed 4 years ago by jezdez
- Needs documentation set
- Needs tests set
- Patch needs improvement set
comment:3 Changed 4 years ago by ambv
- Owner changed from nobody to ambv
- Status changed from new to assigned