Class CachedResponseSuitabilityChecker

java.lang.Object
org.apache.hc.client5.http.impl.cache.CachedResponseSuitabilityChecker

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

    • LOG

      private static final org.slf4j.Logger LOG
    • validityStrategy

      private final CacheValidityPolicy validityStrategy
    • sharedCache

      private final boolean sharedCache
    • staleifError

      private final boolean staleifError
  • Constructor Details

    • CachedResponseSuitabilityChecker

      CachedResponseSuitabilityChecker(CacheValidityPolicy validityStrategy, CacheConfig config)
    • CachedResponseSuitabilityChecker

      CachedResponseSuitabilityChecker(CacheConfig config)
  • Method Details

    • assessSuitability

      public CacheSuitability assessSuitability(RequestCacheControl requestCacheControl, ResponseCacheControl responseCacheControl, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, Instant now)
      Determine if I can utilize the given HttpCacheEntry to respond to the given HttpRequest.
      Since:
      5.4
    • 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, 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, 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
    • isSuitableIfError

      public boolean isSuitableIfError(RequestCacheControl requestCacheControl, ResponseCacheControl responseCacheControl, HttpCacheEntry entry, Instant now)