I have a multilingual site in which I need set cache page enabled for anonymous using Varnish.

But if you enable page caching language is not detected for anonymous in pages without language prefix. This happens because language can't be detected using browser language detection of drupal. In short, if browser language is detected when page cache is enabled the cache could be affected by the user specific language. In the issue linked they provide a code to allow browser language, if you still want do it.

I've found 2 solutions for solve my problem:

1) Use Global Redirect module to redirect users to page language, and apply code of the issue to allow browser language detection. With Global redirect users would be allways redirected to page with language prefix.

2) Don't cache page for anonymous, but send cache control max age header by my own, only for anonymous (I've seen 'Expiration of cached pages' set by drupal only works when drupal page is served from anonymous cache). There exists a module to add cache control max age, and made a control by user role?

What of the solutions do you think is the recommended? There is another way to solve this problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.