Facelets is actually capable of "precompiling". You can control the Facelets refresh period with the context parameter javax.faces.FACELETS_REFRESH_PERIOD
. You can set it to -1
in order to tell JSF to never re-compile/re-parse the Facelets files and actually hold the entire SAX-compiled/parsed XML tree (based on the XHTML compositions) in cache:
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>-1</param-value>
</context-param>
Don't use this setting during development though, or you must restart the whole server on every edit of a Facelets file. Mojarra has a default setting of 2
(meaning, cache will be refreshed every 2 seconds). MyFaces has a default setting of -1
when javax.faces.PROJECT_STAGE
is not set to Development
.
You can if necessary control the Facelets cache by providing a custom FaceletsCacheFactory
and FaceletsCache
. Note that this is only available since JSF 2.1 and thus you'd need to redeclare your faces-config.xml
conform JSF 2.1 in order to get <facelet-cache-factory>
configuration setting to work.
To get a step further, the views which are built based on the XML tree (so, the entire UIViewRoot
) could theoretically also be pooled. MyFaces is currently already making some effort in order to achieve this, see also issue 3664. My fellow Arjan Tijms is in his spare time also looking at it for Mojarra.