liferay页面缓存问题解决
Liferay页面使用缓存,在未登录时,页面只做一次加载,即使对JSP文件修改,页面有时也没法重新加载。但在登录之后,每一个请求每一个页面时都会重新加载。在网上查了很多资料,使用那些方法对一般的JSP页面都有作用,但对Liferay却没有效果。
经过研究发现,Liferay缓存是通过filter实现的,即 com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter,在 system.properties中有对应的设置, com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter=false,则 每次都有对服务器重新请求。
飞速按他说的去做,发现没反映,研究发现,这只是针对开发环境的设置。所以在Tomcat目录中找到
web.xml(D:\lifeportal\tomcat\webapps\ROOT\WEB-INF),打开后修改如下:
将:
<filter>
<filter-name>Layout Cache Filter - Friendly</filter-name>
<filter-class>com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter</filter-class>
<init-param>
<param-name>pattern</param-name>
<param-value>0</param-value>
</init-param>
</filter>
<filter>
<filter-name>Layout Cache Filter - Layout</filter-name>
<filter-class>com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter</filter-class>
<init-param>
<param-name>pattern</param-name>
<param-value>1</param-value>
</init-param>
</filter>
<filter>
<filter-name>Layout Cache Filter - Resource</filter-name>
<filter-class>com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter</filter-class>
<init-param>
<param-name>pattern</param-name>
<param-value>2</param-value>
</init-param>
</filter>
改为:<filter>
<filter-name>Layout Cache Filter - Friendly</filter-name>
<filter-class>com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter</filter-class>
<init-param>
<param-name>pattern</param-name>
<param-value>0</param-value>
</init-param>
</filter>
<filter>
<filter-name>Layout Cache Filter - Layout</filter-name>
<filter-class>com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter</filter-class>
<init-param>
<param-name>pattern</param-name>
<param-value>0</param-value>
</init-param>
</filter>
<filter>
<filter-name>Layout Cache Filter - Resource</filter-name>
<filter-class>com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter</filter-class>
<init-param>
<param-name>pattern</param-name>
<param-value>0</param-value>
</init-param>
</filter>