Making DPM caching locale specific

Issue Statement:

In case of Item Publisher portlet, DPM caches whole HTML fragment. This caching is not locale specific. This creates in-consistent content in multi-lingual site. Consider the scenario below:

  1. User 1 with English as preferred locale, sees detail news article say, news1 in Item Publisher portlet.
  2. When User 2 with Swedish as preferred locale, sees detail of same news article, news1, DPM get that fragment from cache which is in English version.

Resolution:

To resolve this issue, we need to do three things:

  1. Add cache.locale.variation=true to vgnExtTemplating resource
  2. Add RequestContextModifier to vgn-ext-templating application.
  3. Register request.context.modifier=yourRequestContextModifier

We will take all these three separately.

  1. Add cache.locale.variation=true to vgnExtTemplating resource : The cache.locale.variation config parameter tells DPM to add locale found in the request to cache key. This makes caching locale specific. But, it cached based on RequestContext.getLocale() which appears to be browser locale setting. This creates a problem if user have option to select language on your site, which is usually there in case of multi-lingual site.
  2. To resolve above issue, implement custom RequestContextModifer for DPM application which intercepts every request sent to DPM application and put user's preferred locale to RequestContext.

I am giving a dummy RequestContextModifier, which may change depending upon your locale implementation in your site.

  1. public   class  yourReqContextModifier  implements  RequestContextModifier  
  2. {  
  3.     public  ReqContextModifier() {}  
  4.    
  5.     public   void  populate(RequestContext requestContext)  throws  ApplicationException {  
  6.      Locale locale = // Get requested Locale from somewhere   
  7.         if  (locale ==  null ){  
  8.             locale=Locale.ITALIAN;  
  9.             requestContext.setLocale(locale);  
  10.             requestContext.setSessionVariable("cdaLocale" , locale);  
  11.         }  
  12.         else  {  
  13.       requestContext.setLocale(locale);  
  14.             requestContext.setSessionVariable("cdaLocale" , locale);  
  15.         }  
  16.     }  

Compile this class and put it in vgn-ext-templating.war and deploy that new vgn-text-templating.war file to your application server hosting portal.

  1. Register this RequestContextModifier to vgnExtTemplating resource. For registering it, add request.context.modifier=yourReqContextModifier.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值