Problem/Motivation
When using external cache and in some regards the Drupal page cache, the language cookie will keep on being set when it was once for a page (e.g. due to it not existing). This because the Drupal cached the setCookie response.
Cookies being set should not be cached however, so this might kill your external cache (e.g. default Varnish behaviour).
To circumvent this, you could tell Drupal not to cache any response that sets a cookie.
But then there is still the problem in Drupal caching a page without a setCookie and serving that to anyone visiting that page without a cookie, resulting in them not getting the language cookie.
This could also be circumvented by altering the default Drupal page cache behaviour, but it starts to get a little complicated.
Proposed resolution
The easy solution to both problems described above (without fancy circumventions) is having this module set its cookie via JS, or at least having the option to.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | language_cookie-client_side_cookie_setting-3193793-9.patch | 6.93 KB | drubenjamin |
| #3 | interdiff_1_3.txt | 2.01 KB | nginex |
| #3 | language_cookie-client_side_cookie_setting-3193793-3.patch | 6.75 KB | nginex |
Issue fork language_cookie-3193793
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
l_vandamme commentedI've already created a patch for this in the version we're currently using (8.x-1.0).
Comment #3
nginex commentedI cleaned some debug code and removed usage for ES6 standard, it's still not fully supported in some browsers
Comment #4
radelson commentedHere is a patch reworking a bit the JS.
It's using the cookie library provided by core.
I also removed the usage of $( document ).ready
Comment #5
cgoffin commentedHere an updated patch that works on 8.x-1.2.
Comment #6
cgoffin commentedThere was a bug in my previous patch, here the one without the bug.
Comment #7
radelson commentedPatch in #6 doesn't appear to include any Javascript to set the cookie, so that's weird.
Not sure what are the changes made in #5 and #6 apart from removing the clientside code.
Comment #8
gilles_webstanz commentedHello,
I rerolled the patch #4 for version 8.x-1.2.
Comment #9
saso.sotlar commentedSince patches in #5, #6 #8 are either missing JS or contain some old code (or both), rerolled patch from #4 again. It now applies cleanly to latest release version (8.x-1.2) - JS and all required functionality should be there.
Comment #10
jeroentComment #11
daften commentedThis needs rework to apply on 2.0.0
Comment #12
jeroentComment #14
bramdriesenRerolled on 2.x
Comment #16
bramdriesenIssue fork needs a rebase.
Comment #17
bramdriesenComment #19
dieterholvoet commentedComment #20
dieterholvoet commentedComment #21
drubenjamin commentedI've updated the latest patch with two changes to make it work with the latest update.
Comment #23
jeroentMerged to 2.0.x. Thanks!