angular/universal

Weird behavior of SSR with i18n

aleesaan opened this issue · 2 comments

I encountered a weird issue with SSR combined with angular's i18n: when using loadTranslations, it seems like the server creates the translated response only once, and then serves that for every subsequent request.
You can read more details in the issue I opened in the angular repo, where I asked the difference between strings marked with i18n and strings with $localize. I also provided a reproduction repo where you can see the issue in action.

Another side of the issue I don't understand, which seems to be coming from angular/universal, is why it looks like the server caches the first (translated) response it creates, and always serves that one (rather than creating a response for each request). For instance, if I build the app, then run the server, it'll serve me the app in the language I request it first, let's say French; the server response for all subsequent requests will be in French. If I then restart the server, and request the app in e.g. Spanish, the server response will become Spanish for all the subsequent requests. Very weird I'd say!

Is this response actually cached as it looks like? If so, where is it cached? And is there a way to avoid this caching?

Let continue tracking this angular/angular#51624 as Universal is just a wrapper on top of @angular/platform-server and does not do anything special for i18n.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.