22.2. Page fragment caching

Seam uses the <s:cache> tag to solve the problem of page fragment caching in JSF. The<s:cache> tag uses pojoCache internally, so follow the previous steps — place the JARs in the EAR and edit additional configuration options — before using the <s:cache> tag.
The <s:cache> tag stores some rendered content that is rarely updated. For example, the welcome page of our blog displays recent blog entries:

<s:cache key="recentEntries-#{blog.id}" region="welcomePageFragments">
  <h:dataTable value="#{blog.recentEntries}" var="blogEntry">
    <h:column>
      <h3>#{blogEntry.title}</h3>
      <div>
        <s:formattedText value="#{blogEntry.body}"/>
      </div>
    </h:column>
  </h:dataTable>
</s:cache>
The key parameter allows you to store multiple versions of each page fragment. In the above example, there is one cached version per blog. The region parameter determines the cache or region node where all the versions are stored. Different nodes may have differing expiry policies.
The <s:cache> tag does not indicate when the underlying data is updated, so manually remove the cached fragment when a change occurs:

public void post() 
{
  ...
  entityManager.persist(blogEntry);
  cacheProvider.remove("welcomePageFragments", "recentEntries-" + blog.getId() );
}
If changes need not be immediately visible to the user, set up a short expiry period on the cache node.