Training

WASKB015 - Caching Static Files From a Web Module At the Web Server Tutorial

Popular Courses

Browse Our Free Resources

  • whitepapers
  • whitepapers
  • webinars
  • blogs

Our Locations

Training Centres

Vancouver, BC
Calgary, AB
Edmonton, AB
Toronto, ON
Ottawa, ON
Montreal, QC
Hunt Valley
Columbia

locations map

Calgary

550 6th Av SW
Suite 475
Calgary, AB
T2P 0S2

Toronto

821A Bloor Street West
Toronto, ON
M6G 1M1

Vancouver

409 Granville St
Suite 902
Vancouver, BC
V6C 1T2

U.S. Office

436 York Road
Suite 1
Jenkintown, PA
19046

Other Locations

Dallas, TX
Miami, FL

Introduction

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 "com.ibm.servlet.file.esi.timeOut" JVM property. For example: -Dcom.ibm.servlet.file.esi.timeOut=60 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


Feedback


Email Address: *


Very useful Somewhat useful Not bad Needs many corrections


Comments:
*


( * ) = mandatory field