varnish-4.0-configuration-templates icon indicating copy to clipboard operation
varnish-4.0-configuration-templates copied to clipboard

Language variations dont seem to be working

Open antrecu opened this issue 7 years ago • 2 comments

Hi,

Using the VCL provided for a Drupal 7 installation seems to be working fine but when enabling multi language support ( just enable an extra language ) Varnish seems to stop caching pages, so i'm wondering if the VCL configuration provided is taking Language variations into consideration for caching? if you ever get a HIT on varnish it seems that cache works different per Browser. There are multiple modules on Drupal 7 that are related to Languages that set cookies on the backed like Multilink (https://www.drupal.org/project/multilink) for caches pages in Drupal 7 so not sure if this is being handled as well on the provided config?.

i've added the following directive to the vcl_hash() routine to see if that might help but seems to be doing nothing.

sub vlc_hash(){
#...
#Uncomment if different languages are served at the same URL.
if( req.http.Accept-Language ) {
  hash_data(req.http.Accept-Language);
}
}

Thanks for your attention and clarifications.

antrecu avatar Apr 03 '17 14:04 antrecu

Hi!

If your module sets cookies to define the language, the current config should be sufficient: it'll look at different mutations of your cookies and cache those differently.

However, it's possible that your config has code in vcl_recv that does something like "if there are cookies, do not cache", which would bypass the cache as soon as you set a language cookie.

M.

mattiasgeniar avatar Apr 05 '17 13:04 mattiasgeniar

not really, the module sets a Global cookie named "multilink_pl" that is set automatically when a user switches the language, when the cookie is set, varnish always throws MISS instead of HIT. Tried with the same vcl_recv code of the provided config so not sure how to by-pass this cookie and force varnish to cache the pages anyways

antrecu avatar Apr 05 '17 15:04 antrecu