Liferay: Customise the web.xml HeaderFilter added during portlet deployment
I need to customise the deployment of my liferay portlet such that the GWT nocache.js files don't get a 'Expires' HTTP header set.
My war file looks like this:
view.jsp
com.foobar.MyEntryPoint/com.foobar.MyEntryPoint.nocache.js
com.foobar.MyEntryPoint/12312312313213123123123.cache.html
WEB-INF/web.xml
WEB-INF/portlet.xml
WEB-INF/liferay-portlet.xml
... etc
my web.xml
is pretty much empty (only has the displayName)
On deployment this is rewritten my liferay to have a series of filters in particalar:
<filter>
<filter-name>Header Filter</filter-name>
<filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filter-class>
<init-param>
<param-name>filter-class</param-name>
<param-value>com.liferay.portal.servlet.filters.header.HeaderFilter</param-value>
</init-param>
<init-param>
<param-name>Cache-Control</param-name>
<param-value>max-age=315360000, public</param-value>
</init-param>
<init-param>
<param-name>Expires</param-name>
<param-value>315360000</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Header Filter</filter-name>
<url-pattern>*.js</url-pattern>
</filter-mapping>
This filter adds an Expires header for about 2020 to the .nocache.js js files... the trouble is these files really shouldn't be cached (the hint is in the name :)
For development purposes I have worked around this by disabling the filter using:
com.liferay.portal.servlet.filters.header.HeaderFilter=false
in portal-ext.properties globaly. What I what I would like to to is one of the following:
Any ideas how either of these things could be achieved?
Stack: liferay-6.0.1 CE, Windows 7, java 1.6.0_18, GWT 2.0.3
Try to use the url-regex-pattern which is used by Liferay itself:
<filter>
<filter-name>Header Filter</filter-name>
<filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filter-class>
<init-param>
<param-name>filter-class</param-name>
<param-value>com.liferay.portal.servlet.filters.header.HeaderFilter</param-value>
</init-param>
<init-param>
<param-name>url-regex-pattern</param-name>
<!-- the following matches everything except files ending .nocache.js -->
<param-value><![CDATA[^.+(?<!nocache.js)$]]></param-value>
</init-param>
<init-param>
<param-name>Cache-Control</param-name>
<param-value>max-age=315360000, public</param-value>
</init-param>
<init-param>
<param-name>Expires</param-name>
<param-value>315360000</param-value>
</init-param>
</filter>
If you add this to your web.xml it is not added twice during deployment or deleted. I don't have experience with Version 6.0 by now so please verify.
链接地址: http://www.djcxy.com/p/60152.html上一篇: 具有多个服务器实例的Liferay