Web servers can serve static files (HTML, GIF etc.) a lot faster than the Web Container can. This has caused many sites to move static content out of the Web Module and into the web server’s document root. This process is extremely time consuming and error prone, especially, when you have multiple web servers.

WebSphere v5.0.1 and up has static file caching capability at the HTTP server plugin level. Once a static file has been served by the Web Container, it can be cached by the plug-in. All subsequent requests for the file will be handled directly by the plug-in. The need to keep static files in the web server’s document root largely goes away.

Enabling Caching

To enable ESI caching, add these lines to the plugin-config.xml within the <Config> element:

    <Property Name="ESIEnable" Value="true"/> 
    <Property Name="ESIMaxCacheSize" Value="1024"/> 

In v5.0.1, Edge Side Caching (ESI) is disabled by default. In 5.1, it is enabled by default.

The second property – ESIMaxCacheSize – determines the total size of the cache in KB. In the example above the size of the cache is 1MB.

A static file is cached for 5 minutes (300s) by default. If you modify the file in the WAR folder in the application server machine, it will take that much time to see the changes in the browser. You can control the timeout using the “” JVM property. For example: will set the time out to 1 minute.

Issues You Need to Know About

In UNIX, if you are running a process based Apache (as opposed to thread based), every process will build its own cache. You need to be aware of these issues:

  • There is a known security exposure if the static content is protected in the web container using J2EE security. Visit the IBM website for more details and an e-fix.
  • Total memory requirement is ESIMaxCacheSize times the MaxClients value. This can lead to large memory usage.
  • Each process will expire cache at different times. This can lead to unpredictable behavior after you have upgraded an application. To be safe, restart the web server.

Other Resources