Book Image

Primefaces Cookbook Second Edition

Book Image

Primefaces Cookbook Second Edition

Overview of this book

Table of Contents (20 chapters)
PrimeFaces Cookbook Second Edition
Credits
Foreword
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Reducing page load time using content caching


Reducing the page load time can be done by caching the HTML content after initial rendering. PrimeFaces' cache component can be used to cache the content. It supports two providers that enable content management in a cache store. The first provider is for Ehcache (http://ehcache.org) and the second one for Hazelcast (http://hazelcast.com/products/hazelcast).

In this recipe, we will use Ehcache—an open source, standard-based cache used to boost performance, offload the database, and simplify scalability. We will explain how the cache component works in an example with a feed reader wrapped inside the p:cache tag.

Getting ready

The cache provider is configured via a context parameter in web.xml. The provider for Ehcache is configured here:

<context-param>
  <param-name>primefaces.CACHE_PROVIDER</param-name>
  <param-value>org.primefaces.cache.EHCacheProvider</param-value>
</context-param>

A dependency for Ehcache...