M
M
Max2015-04-18 16:01:13
symfony
Max, 2015-04-18 16:01:13

Is it possible to cache a multilingual site with Reverse Proxy without a language in the URL?

The site supports 3 languages, information about the language chosen by the user is stored in Cookies. That is, by going to the /about page and changing the language of the site, the user will always be on the /about URL, no language prefixes are added.
Now we need to implement caching using ReverseProxy (for example, Varnish or SymfonyReverseProxy).
As soon as the first user enters the site, the entire page with the EN language is cached (by default). Further, switching the language does not work, because. Varnish does not see changes in the URL, and the URL does not change either.
The question is how to solve such a problem? Can this be bypassed?
Googling, I saw advice that it’s better to specify the language in the URL:
/en/about
/ru/about
/be/about
Then Varnish will cache everything correctly, and language switching will work again.
As far as I understand, the Vary: Accept-language header cannot help here, since it is set by the browser and remains unchanged when changing the language through Cookies.
I would appreciate advice, thanks.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
WarGot, 2015-04-23
@WarGot

The author did not try to see what events the proxy has, probably there is a read / write cache, is it possible to hang up a lisener that will add the language from the cookies to the cache name before reading, before writing?

M
Max, 2015-04-28
@borNfree

I decided to reach a large audience, since the question is not googled at all: stackoverflow.com/questions/29907496/is-it-possibl...
Suggest solutions :)

D
Denis, 2015-04-29
@prototype_denis

If you don't want the language in the url, then translate it on the client.
materializecss.com is a good example of this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question