Class CachingResponseFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    @WebFilter(filterName="Caching Response filter",
               urlPatterns="/*")
    public class CachingResponseFilter
    extends Object
    implements javax.servlet.Filter
    Assist in cache management for individual profile pages. Must be enabled in runtime.properties. Only works for users who are not logged in. The search index must be configured to keep an ETAG on each individual's record. The ETAG is a hash of the record's content and is updated each time the individual is re-indexed. But this ETAG is not sufficient, since the page may have different versions for different languages. So we append a hash of the Locales from the request to the ETAG to make it unique. NOTE: If we allow users to choose their preferred languages, the LocalSelectionFilter must execute before this one. When an external cache (e.g. Squid) is asked for an individual's profile page, it will ask VIVO whether the version in the cache is still current, and to provide a new version if it is not. This is a conditional request. When a conditional request is received, this filter will check to see whether the request is on behalf of a logged-in user. If so, a fresh response is generated, with a Cache-Control header that should prevent the cache from storing that response. If the requesting user is not logged in, this filter will ask the search engine for the ETAG on the requested individual. If it is the same as the ETAG supplied by the cache in the request, then the response is 304 Not Modified. Otherwise, a fresh response is generated. An unconditional request may mean that there is no external cache, or that the cache doesn't have a copy of this particular page.
    • Constructor Detail

      • CachingResponseFilter

        public CachingResponseFilter()
    • Method Detail

      • init

        public void init​(javax.servlet.FilterConfig fc)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Filter
        Throws:
        javax.servlet.ServletException
      • destroy

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

        public void doFilter​(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain chain)
                      throws IOException,
                             javax.servlet.ServletException
        Process an HTTP request.
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        IOException
        javax.servlet.ServletException