Package hudson

Class ResponseHeaderFilter

  • All Implemented Interfaces:

    public class ResponseHeaderFilter
    extends Object
    implements javax.servlet.Filter
    This filter allows you to modify headers set by the container or other servlets that are out of your control. The particular headers you wish to change are configured in web.xml.

    One particular header you you may wish to deal with is "Cache-Control: no-cache" This is a problem with Tomcat when security is used. Continue reading for further details.

    If a web app has a <security-constraint> in its web.xml, Tomcat will add a Cache-Control header to every file it serves from that location. This header will prevent browsers from caching the file locally and this drastically slows down Hudson page load times.

    To enable this filter, edit the web.xml file to include:

                 <param-value>max-age=86400, public</param-value>
     And down below that:

    In the case of the tomcat cache problem, it is important that the url-pattern for the filter matches the url-pattern set for the security-constraint.

    Mike Wille
    • Constructor Detail

      • ResponseHeaderFilter

        public ResponseHeaderFilter()
    • Method Detail

      • init

        public void init​(javax.servlet.FilterConfig filterConfig)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Filter
      • doFilter

        public void doFilter​(javax.servlet.ServletRequest req,
                             javax.servlet.ServletResponse resp,
                             javax.servlet.FilterChain chain)
                      throws IOException,
        Specified by:
        doFilter in interface javax.servlet.Filter
      • destroy

        public void destroy()
        Specified by:
        destroy in interface javax.servlet.Filter