Leonardo Uribe
added a comment - 10/Jun/11 04:19 This issue depends on MYFACES-3169 . Some conclusions arise in that issue:
1. facelets user tags cannot cache EL Expressions
2. There is a potential risk of bad caching if a template is called with different number of parameters.
The second one makes not possible to set this optimization by default on cases where ui:param is used, because we can't warrant proper operation. Suppose this
a.xhtml
<ui:composition template="c.xhtml">
<ui:param name="var1" value="value1"/>
</ui:composition>
b.xhtml
<ui:composition template="c.xhtml">
<ui:param name="var1" value="value1"/>
<ui:param name="var2" value="value2"/>
</ui:composition>
c.xhtml
<ui:composition>
<h:outputText value="#
{var1}
/>
<h:outputText value="#
{var2}/>
</ui:composition>
if a.xhtml view is constructed before b.xhtml, #{var2}
will be cached, even if this is not wanted and then when b.xhtml is called, the expression will not work correctly.
In practice, it is up to the app develover to decide if this stuff applies for its particular case. The patch proposed here requires more work after commit the one on MYFACES-3169 .

With the corrections done on c:set and ui:param, we can limit effectively the "scope" of the variables and detect early if we should cache it or not. The latest evidence shows it is not possible to set the improvement to other value than noCache by default, so the best is let the user decide to cache or not expressions, and the mode that applies for your project.

Leonardo Uribe
added a comment - 14/Jun/11 22:46 Attached corrected patch ( MYFACES-3160 -8) after commit solution for MYFACES-3169 .
After thinking about this issue, the param to activate the this improvement works like this:
/**
Indicates if expressions generated by facelets should be cached or not. Default is noCache. There there are four modes:
<ul>
<li>always: Only does not cache when expressions are inside user tags or the expression contains a variable resolved using VariableMapper</li>
<li>allowCset: Like always, but does not allow cache when ui:param was used on the current template context</li>
<li>strict: Like allowCset, but does not allow cache when c:set with var and value properties only is used on the current page context</li>
<li>noCache: All expression are created each time the view is built</li>
</ul>
*/
@JSFWebConfigParam(since="2.0.8", defaultValue="noCache", expectedValues="noCache, strict, allowCset, always")
public static final String INIT_PARAM_CACHE_EL_EXPRESSIONS = "org.apache.myfaces.CACHE_EL_EXPRESSIONS";
With the corrections done on c:set and ui:param, we can limit effectively the "scope" of the variables and detect early if we should cache it or not. The latest evidence shows it is not possible to set the improvement to other value than noCache by default, so the best is let the user decide to cache or not expressions, and the mode that applies for your project.