Class CachedResponseSuitabilityChecker


  • class CachedResponseSuitabilityChecker
    extends java.lang.Object
    Determines whether a given HttpCacheEntry is suitable to be used as a response for a given HttpRequest.
    • Field Detail

      • LOG

        private static final org.slf4j.Logger LOG
      • sharedCache

        private final boolean sharedCache
      • staleifError

        private final boolean staleifError
    • Constructor Detail

      • CachedResponseSuitabilityChecker

        CachedResponseSuitabilityChecker​(CacheConfig config)
    • Method Detail

      • requestMethodMatch

        boolean requestMethodMatch​(org.apache.hc.core5.http.HttpRequest request,
                                   HttpCacheEntry entry)
      • requestUriMatch

        boolean requestUriMatch​(org.apache.hc.core5.http.HttpRequest request,
                                HttpCacheEntry entry)
      • requestHeadersMatch

        boolean requestHeadersMatch​(org.apache.hc.core5.http.HttpRequest request,
                                    HttpCacheEntry entry)
      • isResponseNoCache

        boolean isResponseNoCache​(ResponseCacheControl responseCacheControl,
                                  HttpCacheEntry entry)
        Determines if the given HttpCacheEntry requires revalidation based on the presence of the no-cache directive in the Cache-Control header.

        The method returns true in the following cases: - If the no-cache directive is present without any field names (unqualified). - If the no-cache directive is present with field names, and at least one of these field names is present in the headers of the HttpCacheEntry.

        If the no-cache directive is not present in the Cache-Control header, the method returns false.

      • isConditional

        public boolean isConditional​(org.apache.hc.core5.http.HttpRequest request)
        Is this request the type of conditional request we support?
        Parameters:
        request - The current httpRequest being made
        Returns:
        true if the request is supported
      • allConditionalsMatch

        public boolean allConditionalsMatch​(org.apache.hc.core5.http.HttpRequest request,
                                            HttpCacheEntry entry,
                                            java.time.Instant now)
        Check that conditionals that are part of this request match
        Parameters:
        request - The current httpRequest being made
        entry - the cache entry
        now - right NOW in time
        Returns:
        true if the request matches all conditionals
      • hasUnsupportedConditionalHeaders

        boolean hasUnsupportedConditionalHeaders​(org.apache.hc.core5.http.HttpRequest request)
      • hasSupportedEtagValidator

        boolean hasSupportedEtagValidator​(org.apache.hc.core5.http.HttpRequest request)
      • hasSupportedLastModifiedValidator

        boolean hasSupportedLastModifiedValidator​(org.apache.hc.core5.http.HttpRequest request)
      • etagValidatorMatches

        boolean etagValidatorMatches​(org.apache.hc.core5.http.HttpRequest request,
                                     HttpCacheEntry entry)
        Check entry against If-None-Match
        Parameters:
        request - The current httpRequest being made
        entry - the cache entry
        Returns:
        boolean does the etag validator match
      • lastModifiedValidatorMatches

        boolean lastModifiedValidatorMatches​(org.apache.hc.core5.http.HttpRequest request,
                                             HttpCacheEntry entry,
                                             java.time.Instant now)
        Check entry against If-Modified-Since, if If-Modified-Since is in the future it is invalid
        Parameters:
        request - The current httpRequest being made
        entry - the cache entry
        now - right NOW in time
        Returns:
        boolean Does the last modified header match