Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

22.2. Page fragment caching


The <s:cache> tag is Seam's solution to the problem of page fragment caching in JSF. <s:cache> uses pojoCache internally, so you will need to follow the previous steps — place the JARs in the EAR and edit additional configuration options — before you can use it.
<s:cache> 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>
Copy to Clipboard Toggle word wrap
The key lets you store multiple versions of each page fragment. In this case, there is one cached version per blog. The region determines the cache or region node where all versions are stored. Different nodes may have differing expiry policies.
The <s:cache> cannot tell when the underlying data is updated, so you will need to manually remove the cached fragment when a change occurs:
public void post() { 
  ... 
  entityManager.persist(blogEntry); 
  cacheProvider.remove("welcomePageFragments", 
                       "recentEntries-" + blog.getId()); 
}
Copy to Clipboard Toggle word wrap
If changes need not be immediately visible to the user, you can set up a short expiry period on the cache node.
Nach oben
Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können. Entdecken Sie unsere neuesten Updates.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Theme

© 2025 Red Hat