Cache

Cache component is used to reduce page load time by caching the content in a global cache after the initial rendering. Various cache providers are supported like ehcache and hazelcast. Showcase use actually this component to render source examples for every PrimeFaces components. Why? Because parsing an xhtml file takes time, and since the rendering won't change during the whole lifecycle of the application, it's better to cache the content.

  • tabscode.xhtml demonstrate how to use cache component declaratively
  • ShowcaseUtil demonstrate how to use cache API programmatically

<p:tabView var="entry" value="#{value}">
<p:tab title="#{entry.title}" >
    <p:cache region="sources" key="#{entry}"
             disabled="#{facesContext.application.projectStage eq 'Development'}">
        <pre name="code" class="brush:#{entry.type}">#{entry.value}</pre>
    </p:cache>
</p:tab>

<f:facet name="static-tabs">
    <ui:insert />
</f:facet>
    </p:tabView>