I want to configure varnish on my drupal 8 multilingual website and I have a block that appears on a page whose path is /my-test . So in french the url would be like this : /fr/my-test whereas in english /my-test . In this block, I simply use:
$lang = \Drupal::languageManager()->getCurrentLanguage()->getId(); to detect the language and then display news depending on this language.
so when the url is /my-test > the language is english (default)> the block displays news related to the world.
when the url is /fr/my-test > the language is french > the block displays news related to the France.
My question is, if varnish is used and pages like /my-test is cached. If at first place, a user enters /my-test and the block displays news about the world then after that, another user visits /my-test/fr . Will the block display news about the world (because the page is cached) despite having /fr in the url? or will it display the right content (news related to France)?
I suppose that
$lang detects the language from the url prefix not from the user's browser.