Liferay: Configure web.xml HeaderFilter added during portlet deployment

I need to configure the deployment of my liferay portlet so that the GWT nocache.js files do not receive the "Expires" HTTP header set.

My war file is as follows:

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 is web.xmlpretty empty (only has displayName)

When deployed, this is rewritten by my lifelong line to have a number 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 the Expires header by 2020 to the .nocache.js js files ... the problem is that these files really should not be cached (a hint in the name :)

For development purposes, I worked on this by disabling the filter using:

com.liferay.portal.servlet.filters.header.HeaderFilter=false

in portal -ext.properties globaly. What I would like to do is one of the following:

  • HeaderFilter . .
  • init-param HeaderFilter, -, .nocache.js.

, ?

: liferay-6.0.1 CE, Windows 7, java 1.6.0_18, GWT 2.0.3

+3
1

url-regex, Liferay:

<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>

web.xml, . 6.0, , , .

+3

Source: https://habr.com/ru/post/1744521/


All Articles