I have a Play Framework 2 application with intertionalization.
I use the CacheApi embedded in Play (ehCache) with standard configuration. I made an example with index page:
@Inject @NamedCache("session-cache") CacheApi cache;
then
@Cached(key = "index")
public Result index() {
//Controller.changeLang("fr");
return ok(index.render(this.userProvider,"c-layout-header-fullscreen",NEWS_FORM));
}
When i launch first page and refresh it seems to work but i have a method to change the lang (or detect automatically the browser lang/country)
public Result changeLanguage(String code) {
Controller.changeLang(Language.findByCode(code).code);
return redirect(controllers.routes.Application.index().toString());
}
when i change the language the same page as before cached in first language page ordered is displayed.
How i can specify the cache for a language (if i have 3 languages, 3 differents index page cached). Same problem for DB translation i want to chache result query but following the language it will be different. I want to cache the translation query because it will use DB lot of.
what is difference between session-cache, db-cache, user-cache ?