Configure Edge Side Include caching
The web server plug-in contains a built-in ESI processor that can cache whole pages, as well as fragments, providing a higher cache hit ratio. The cache implemented by the ESI processor is an in-memory cache, not a disk cache, therefore, the cache entries are not saved when the web server is restarted.
Edge Side Include (ESI) is configured through the plugin-cfg.xml file.
When a request is received by the web server plug-in, it is sent to the ESI processor, unless the ESI processor is disabled. It is disabled by default. If a cache miss occurs, a Surrogate-Capabilities header is added to the request and the request is forwarded to the WebSphere Application Server. If servlet caching is enabled in the application server, and the response is edge cacheable, the application server returns a Surrogate-Control header in response to the WAS plug-in.
The value of the Surrogate-Control response header contains the list of rules used by the ESI processor to generate the cache ID. The response is then stored in the ESI cache, using the cache ID as the key. For each ESI include tag in the body of the response, a new request is processed so that each nested include results in either a cache hit or another request that forwards to the application server. When all nested includes have been processed, the page is assembled and returned to the client.
The ESI processor is configurable through the WebSphere web server plug-in configuration file plugin-cfg.xml. The following is an example of the beginning of this file, which illustrates the ESI configuration options.
<?xml version-"1.0"?> <Config> <Property Name="esiEnable" Value="false"/> <Property Name="esiMaxCacheSize" Value="1024"/> <Property Name="esiInvalidationMonitor" Value="false"/>
Tasks
- The first option, esiEnable, can be used to enable the ESI processor by setting the value to true. ESI is disabled by default. If ESI is disabled, then the other ESI options are ignored.
- The second option, esiMaxCacheSize, is the maximum size of the cache in 1K byte units. The default maximum size of the cache is 1 megabyte.
If the first response has a Content-Length response header, the web server plug-in checks for the response size. If the size of the response body is larger than the available ESI caching space, the response passes through without being handled by ESI.
Some parent responses have nested ESI includes. If a parent response is successfully stored in the ESI cache, and any subsequent nested include has a Content-length header that specifies a size larger than the available space in the ESI cache, but smaller than the value specified for esiMaxCacheSize property, the plug-in ESI processor evicts other cache elements until there is enough space for the nested include in the ESI cache.
- The third option, esiInvalidationMonitor, specifies if the ESI processor should receive invalidations from the application server. ESI works well when the web servers following a threading model are used, and only one process is started. When multiple processes are started, each process caches the responses independently and the cache is not shared. This could lead to a situation where, the system's memory is fully used up by ESI processor. There are three methods by which entries are removed from the ESI cache: first, an entry expiration timeout occurs; second, an entry is purged to make room for newer entries; or third, the application server sends an explicit invalidation for a group of entries. For the third mechanism to be enabled, the esiInvalidationMonitor property must be set to true and the DynaCacheEsi application must be installed on the application server. The DynaCacheEsi application is located in...
installableApps/DynaCacheEsi.ear
If the ESIInvalidationMonitor property is set to true but the DynaCacheEsi application is not installed, then errors occur in the web server plug-in and the request fails.
- This ESI processor is monitored through the CacheMonitor application. For the ESI processor cache to be visible in the CacheMonitor, the DynaCacheEsi application must be installed, and the ESIInvalidationMonitor property must be set to true in the plugin-cfg.xml file.
- When WAS is used to serve static data, such as images and HTML on the application server, the URLs are also cached in the ESI processor. This data has a default timeout of 300 seconds. We can change the timeout value by adding the property com.ibm.servlet.file.esi.timeOut to the JVM command line parameters. The following example shows how to set a one minute timeout on static data cached in the plug-in:
-Dcom.ibm.servlet.file.esi.timeOut=60
For information about configuring alternate URL, refer to the Configure alternate URL topic.
Subtopics
Use the dynamic cache service Task overview: Using the dynamic cache service to improve performance Web server plug-in properties