Develop > Tailoring > Web tier > Setting web client preferences > Optimize web client cache control

Optimize web client cache control

Applies to User Roles:
System Administrator

You can define the web client cache control from the following control file on the Web tier server: <webtier>/WEB-INF/classes/application-context.xml. The web tier uses the incoming request URL to determine whether to apply one of the following cache filtering rules:

  • cacheFilter

  • neverCacheFilter

When the neverCacheFilter rule applies, the response page or resource will never be cached in the user's browser. When the cacheFilter rule applies, the user's browser caches the response page or resource for a period of time specified in the max-age value (in seconds).

The cacheControlProxy bean defines which web resources the cacheFilter and neverCacheFilter rules apply to. For example, the Web tier uses the cacheFilter rule for any web resources whose path matches /images/**, and sets the Expires' or 'Cache-Control' HTTP header in the response. The Web tier uses the neverCacheFilter rule on any web resources whose path matches /**/*.jsp, and sets the corresponding HTTP header in the response to disable browser caching for the matched resources.

Note: HPE recommends that you do not change the default settings in the cacheControlProxy bean.

      <bean id="cacheControlProxy" class="org.acegisecurity.util.FilterChainProxy">
<property name="filterInvocationDefinitionSource">
<value>
PATTERN_TYPE_APACHE_ANT
/images/**=cacheFilter
/js/**=cacheFilter
/css/**=cacheFilter
/cwc/images/**=cacheFilter
/cwc/js/**=cacheFilter
/cwc/css/**=cacheFilter
/cwc/tree/**=cacheFilter
/gwt/**=cacheFilter
/gxt/**=cacheFilter
/*.do*=neverCacheFilter
/**/*.jsp=neverCacheFilter
/*.jsp=neverCacheFilter
</value>
</property>
</bean>

As of version 9.32, the directory structure of the Web tier has been modified to reflect the current build number of the Web tier. These changes were implemented because the SM Web tier is typically updated every few months. When these updates occur, it is sometimes necessary for users to clear their browser cache. For enterprise clients that have tens of thousands of users, getting all of those users to do this requirement is onerous. With this revised implementation, users will no longer need to clear their browser cache.

HPE recommends setting the max-age value to a value not less than 15552000 seconds (6 months) to better utilize browser cache.

To change the max-age value:

  1. Open the file <webtier>/WEB-INF/classes/application-context.xml in a text editor.
  2. In the cacheFilter bean section, set the max-age property to an appropriate value (the default is 1555200 seconds):
  3.  <bean id="cacheFilter" class="com.hp.ov.cwc.web.CacheControlFilter">
    <property name="headers">
    <map>
    <entry key="Expires"><value>Sat, 6 May 2017 12:00:00 GMT</value></entry>
    <entry key="Cache-Control"><value>public, max-age=1555200</value></entry>
    </map>
    </property>
    </bean>

    The cacheFilter bean defines when cached web resources will expire (from the Expires key) or how long the user's browser will cache web resources (from the max-age value, if any). The max-age value supersedes the Expires value. For example, if you set the max-age to 1555200 seconds (default), the user’s browser caches web resources for up to 180 days.

  4. Restart the web application server for your change to take effect.