wagtailtrans
wagtailtrans copied to clipboard
Is it necessary to set language cookie on every response in TranslationMiddleware?
Issue summary
In TranslationMiddleware on process_response "set_cookie" is executed on every response - even when proper cookie for specific language is already set. This leads to problem with proxies and caching. If response sets a cookie most standard proxy configuration will prevent this response from being cached (304 Not modfied etc)
How to reproduce?
- Open a TranslateableSite with enabled TranslationMiddleware
- You'll see "set-cookie: django_language=pl; Path=/"
- You'll see above everytime in response
Technical details
Python version: 3.6.4 Django version: 2.2.6 Wagtail version: 2.6.3 Wagtaltrans version: 2.0.6
If a proper check can be implemented for the cookie if the value doesn't change, I don't see any problems with changing this to only set it when the value changes.