I added the following code to the web.xml of my Tomcat (version 9) server:
<filter>
<filter-name>CachingFilter</filter-name>
<filter-class>org.apache.catalina.filters.ExpiresFilter</filter-class>
<init-param>
<param-name>ExpiresDefault</param-name>
<param-value>access plus 14 days</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CachingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
It works absolutely fine on any images, scripts, subpages, everything. The response contains an "Expires" header for all resources.
But for the root resource there is no such header and I don´t understand why. There is no error or warning in the logs or anything. Is there maybe a special handling for the root resource so that caching is disabled for that?
EDIT
I activated the logs of the ExpiresFilter to see more details but the logs indicate that the expires header for the root resource is set correctly.
org.apache.catalina.filters.ExpiresFilter.onBeforeWriteResponseBody Request [/] with response status [200] content-type [text/html;charset=UTF-8], set expiration date [10/3/22 4:33 PM]
But the response simply does not contain a Expires-Header or any other caching header.