实现过程
第一步 启用动态高速缓存服务
启用过程如下:
1. 打开WebSpere Application Server的管理控制台。
2. 在管理控制台中,单击“服务器->应用程序服务器->WebSphere_Portal->容器服务->动态高速缓存服务”。
3. 选择服务器启动时启用服务。
4. 单击应用或确定。
5. 保存配置
第二步 配置 Servlet 高速缓存
1. 在管理控制台中,单击控制台导航树中的“服务器->应用程序服务器->WebSphere_Portal->Web容器设置->Web容器”。
2. 选择“配置”选项卡下的启用 servlet 高速缓存。
3. 单击应用或确定。
4. 保存配置。
第三步 使用cachespec.xml文件配置可高速缓存的对象
编写针对helloworld Portlet的cachespec.xml文件(要了解cachespec.xml文件相关元素,请参考WebSphere Application Server的inforcenter,具体URL:http://www-01.ibm.com/software/webservers/appserv/was/library/)。
内容如下:注意红色部分,要正确指定cachespec.dtd文件位置,一般情况下是在安装portal的appserver/properties目录下。
<?xml version="1.0" ?>
<!DOCTYPE cache SYSTEM "/opt/WebSphere/AppServer/properties/cachespec.dtd">
<cache>
<cache-entry>
<class>servlet</class>
<name>/helloworld/jsp/html/HelloWorldPortletView.jsp</name>
<cache-id>
<component id="*" type="parameter">
<required>false</required>
</component>
<component id="" type="pathinfo">
<required>false</required>
</component>
<component id="host" type="header">
<required>false</required>
</component>
<timeout>180</timeout>
</cache-id>
</cache-entry>
</cache>
请注意:
<class>servlet</class>
<name>/helloworld/jsp/html/HelloWorldPortletView.jsp</name>
此部分,指定需要缓存的具体文件(相对路径)。
编写好cachespec.xml文件后,需要把该文件放到此Portlet具体部署的文件系统的指定位置: