This blog explains the steps required to setup EhCache in AEM. AEM based CMS applications leverage caching at one of the following layers.
AEM instance can take advantage of Content Delivery Networks (CDN) to cache all the static content be its HTML pages, images or Videos. Once a static content gets published via the Content Delivery Network, it gets cached on the CDN for a particular duration. For, e.g., Fastly, Akamai
Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. Varnish Cache is fast. It sits between CDN and Application Server and boost performance with its in-memory accelerator anywhere between 5x-10x over using Apache. It gives an additional check on Dos Attacks and can help to avoid Dog-pile effect when CDN cache gets invalidated.
AEM dispatcher module can be installed on the Apache HTTP server. It acts as a reverse proxy with a local disk cache. It supports event based cache eviction and authoring, or the publishing instances can send events of deleting and invalidating cache files on these servers.
AEM Application Cache is the last layer in the AEM Caching strategy. It's quite useful in the personalization services, where many components need a real-time business computation before getting rendered and cannot be cached in above three caching layers.
There are various options to facilitate in-memory Application caching using Redis, EhCache or MemCache. Although it's standard practice in AEM space, I haven’t seen any quick step documentation. Hence, I thought to put them in a blog using ehCache. It can be easily modified to work with other caching implementations.
Make sure to use the updated version of the jars.
Also, append the Ehcache in the Embed-Dependency in case you are using maven-bundle-plugin configuration.