Class PushCacheFilter

  • All Implemented Interfaces:

    @ManagedObject("Push cache based on the HTTP \'Referer\' header")
    public class PushCacheFilter
    extends java.lang.Object
    implements javax.servlet.Filter

    A filter that builds a cache of secondary resources associated to primary resources.

    A typical request for a primary resource such as index.html is immediately followed by a number of requests for secondary resources. Secondary resource requests will have a Referer HTTP header that points to index.html, which is used to associate the secondary resource to the primary resource.

    Only secondary resources that are requested within a (small) time period from the request of the primary resource are associated with the primary resource.

    This allows to build a cache of secondary resources associated with primary resources. When a request for a primary resource arrives, associated secondary resources are pushed to the client, unless the request carries If-xxx header that hint that the client has the resources in its cache.

    If the init param useQueryInKey is set, then the query string is used as as part of the key to identify a resource

    • Constructor Summary

      Constructor Description
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearPushCache()  
      void destroy()  
      void doFilter​(javax.servlet.ServletRequest req, javax.servlet.ServletResponse resp, javax.servlet.FilterChain chain)  
      java.util.Map<java.lang.String,​java.lang.String> getPushCache()  
      void init​(javax.servlet.FilterConfig config)  
      void renewPushCache()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PushCacheFilter

        public PushCacheFilter()
    • Method Detail

      • init

        public void init​(javax.servlet.FilterConfig config)
                  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)
        Specified by:
        doFilter in interface javax.servlet.Filter
      • destroy

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

        @ManagedAttribute("The push cache contents")
        public java.util.Map<java.lang.String,​java.lang.String> getPushCache()