Class HttpCachingFilter


  • public class HttpCachingFilter
    extends Object
    This class is used to apply the filter.
    • Method Detail

      • isValidCacheEntry

        public static boolean isValidCacheEntry​(CachableResponse cachedResponse,
                                                org.apache.synapse.MessageContext synCtx)
        If the cached response is expired, response needs to be fetched again. And if the cached response have the no-cache header, existing cached response needs to be validated with the backend by sending a request with If-None-Match header with ETag value. This method returns whether a request needs to be sent to the backend or not.
        Parameters:
        cachedResponse - The cached response.
        synCtx - The message context.
        Returns:
        True if response need to validated with backend.
      • setAgeHeader

        public static void setAgeHeader​(CachableResponse cachedResponse,
                                        org.apache.axis2.context.MessageContext msgCtx)
        This method sets the Age header.
        Parameters:
        cachedResponse - The cached response to be returned.
        msgCtx - The messageContext.
      • setResponseCachedTime

        public static void setResponseCachedTime​(Map<String,​String> headers,
                                                 CachableResponse response)
                                          throws ParseException
        Set the response fetched time in milliseconds.
        Parameters:
        headers - Transport headers.
        response - Response to be cached.
        Throws:
        ParseException - throws exception if exception happen while parsing the date.
      • isNoStore

        public static boolean isNoStore​(org.apache.axis2.context.MessageContext msgCtx)
        This method returns whether no-store header exists in the response.
        Parameters:
        msgCtx - MessageContext with the transport headers.
        Returns:
        Whether no-store exists or not.