Hello, i did a step by step analysis of the problem using eclipse debugger and i found the culprit. Before i submit a bugreport, can someone confirm me this is unexpected behaviour?
Inside com.xpn.xwiki.internal.cache.rendering.DefaultRenderingCache.getRenderedContent(DocumentReference documentReference, String source, XWikiContext context), there is a call to this.cache.get(documentReference, source, getAction(context), context.getLanguage(), getRequestParameters(context)); which uses this information to generate a cache Key that is then looked up in cache. However, getRequestParameters(context) in my case is returning {menu=[Ljava.lang.String;@3e5da853, xpage=[Ljava.lang.String;@76d60121} where it should return something like {menu={SysAdminRmi.Menu}, xpage={plain}} As a result, my cache key change at each reaquest because values are not properly used and so even if my page is cache, it's never rendered from cache. Reason, behind this is this code in getRequestParameters: Map<String, String> parameters = context.getRequest().getParameterMap(); ... return parameters.toString(); This map is generated by com.xpn.xwiki.web.XWikiServletRequest.getParameterMap, and is Map<String,Object> and not a Map<String,String>! Here is the proving code public Map getParameterMap() { Map newMap = new HashMap(); Map map = this.request.getParameterMap(); Iterator it = map.keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); Object value = map.get(key); if (value instanceof String) { newMap.put(key, filterString((String) value)); } else if (value instanceof String[]) { newMap.put(key, filterStringArray((String[]) value)); } else { newMap.put(key, value); } } return map; } Clearly, In my case, catalina request facade does decode so that ParameterMap return Map<String,String[1 ]> instead of Map<String,String>. Consequences? Cache only works when there are no request parameters. Is there some way for me to replace DefaultRenderingCache with another implementation i write that does not have this issue, as a temporary solution? ----- Mail original ----- De: "Thomas Mortagne" <thomas.morta...@xwiki.com> À: "XWiki Users" <users@xwiki.org> Envoyé: Mercredi 5 Décembre 2012 18:05:59 Objet: Re: [xwiki-users] xwiki render cache not working? On Wed, Dec 5, 2012 at 3:29 PM, David Delbecq <david.delb...@meteo.be>wrote: > Hello, > > i have a specific wiki page that is quite slow to render because some > groovy code and macros in there are quite slow. Fortunately, content does > not change often, si i tried to make it faster for user by using cache > rendering. > > Here is what is inside my xwiki.cfg: > > > xwiki.rendering.defaultCacheDuration=3600 > > And here is my xwiki.properties > > > core.renderingcache.enabled=true > core.renderingcache.documents=wiki:.* > core.renderingcache.size=200 > # Default value is 300 (5 min). > # core.renderingcache.duration=300 > > I have also this inside my page: > > > {{velocity}} > $context.setCacheDuration(60) > //complex content here that has a custom groovy macro and a velocity > include > {{/velocity}} > > > {{groovy}} > System.out.println("***************************************phone menu not > in cache") > {{/groovy}} > > > And i see in my log that, everytime, the System.out is executed, meaning > the render cache is not used. What's my configuration problem? What did i > miss? > > Note: using xwiki 4.1.2 and the url i try is > http://server/xwiki/bin/view/MySpace/MyPage?menu=Test.Menu&xpage=plain > > Thank you. > > David Delbecq > > _______________________________________________ > users mailing list > users@xwiki.org > http://lists.xwiki.org/mailman/listinfo/users > Rendering cache works well for me. First of all, not that your are mixing two different features here: what you find in xwiki.cfg and $context.setCacheDuration() are old caching system which is maintained for retro-compatibility reasons only in xwiki/1.0 syntax. Now about the more generic rendering cache located in xwiki.properties, is your wiki name really "wiki" ? Because here you indicated that you wanted to cache all the pages in the wiki which has "wiki" as identifier. If you are in a single wiki mode (XWiki Enterprise for example) you can simply remove the wiki part as in core.renderingcache.documents=Space.Page -- Thomas Mortagne _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users