public CacheSuitability assessSuitability(final RequestCacheControl requestCacheControl,
                                              final ResponseCacheControl responseCacheControl,
                                              final HttpRequest request,
                                              final HttpCacheEntry entry,
                                              final Instant now) {
        if (!requestMethodMatch(request, entry)) {
            LOG.debug("Request method and the cache entry method do not match");
            return CacheSuitability.MISMATCH;
        }

        if (!requestUriMatch(request, entry)) {
            LOG.debug("Target request URI and the cache entry request URI do not match");
            return CacheSuitability.MISMATCH;
        }

        if (!requestHeadersMatch(request, entry)) {
            LOG.debug("Request headers nominated by the cached response do not match those of the request associated with the cache entry");
            return CacheSuitability.MISMATCH;
        }

        if (!requestHeadersMatch(request, entry)) {
            LOG.debug("Request headers nominated by the cached response do not match those of the request associated with the cache entry");
            return CacheSuitability.MISMATCH;
        }

        if (requestCacheControl.isNoCache()) {
            LOG.debug("Request contained no-cache directive; the cache entry must be re-validated");
            return CacheSuitability.REVALIDATION_REQUIRED;
        }

        if (isResponseNoCache(responseCacheControl, entry)) {
            LOG.debug("Response contained no-cache directive; the cache entry must be re-validated");
            return CacheSuitability.REVALIDATION_REQUIRED;
        }

        if (hasUnsupportedConditionalHeaders(request)) {
            LOG.debug("Response from cache is not suitable due to the request containing unsupported conditional headers");
            return CacheSuitability.REVALIDATION_REQUIRED;
        }

        if (!isConditional(request) && entry.getStatus() == HttpStatus.SC_NOT_MODIFIED) {
            LOG.debug("Unconditional request and non-modified cached response");
            return CacheSuitability.REVALIDATION_REQUIRED;
        }

        if (!allConditionalsMatch(request, entry, now)) {
            LOG.debug("Response from cache is not suitable due to the conditional request and with mismatched conditions");
            return CacheSuitability.REVALIDATION_REQUIRED;
        }

        final TimeValue currentAge = validityStrategy.getCurrentAge(entry, now);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Cache entry current age: {}", currentAge);
        }
        final TimeValue freshnessLifetime = validityStrategy.getFreshnessLifetime(responseCacheControl, entry);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Cache entry freshness lifetime: {}", freshnessLifetime);
        }

        final boolean fresh = currentAge.compareTo(freshnessLifetime) < 0;

        if (!fresh && responseCacheControl.isMustRevalidate()) {
            LOG.debug("Response from cache is not suitable due to the response must-revalidate requirement");
            return CacheSuitability.REVALIDATION_REQUIRED;
        }

        if (!fresh && sharedCache && responseCacheControl.isProxyRevalidate()) {
            LOG.debug("Response from cache is not suitable due to the response proxy-revalidate requirement");
            return CacheSuitability.REVALIDATION_REQUIRED;
        }

        if (fresh && requestCacheControl.getMaxAge() >= 0) {
            if (currentAge.toSeconds() > requestCacheControl.getMaxAge() && requestCacheControl.getMaxStale() == -1) {
                LOG.debug("Response from cache is not suitable due to the request max-age requirement");
                return CacheSuitability.REVALIDATION_REQUIRED;
            }
        }

        if (fresh && requestCacheControl.getMinFresh() >= 0) {
            if (requestCacheControl.getMinFresh() == 0 ||
                    freshnessLifetime.toSeconds() - currentAge.toSeconds() < requestCacheControl.getMinFresh()) {
                LOG.debug("Response from cache is not suitable due to the request min-fresh requirement");
                return CacheSuitability.REVALIDATION_REQUIRED;
            }
        }

        if (requestCacheControl.getMaxStale() >= 0) {
            final long stale = currentAge.compareTo(freshnessLifetime) > 0 ? currentAge.toSeconds() - freshnessLifetime.toSeconds() : 0;
            if (LOG.isDebugEnabled()) {
                LOG.debug("Cache entry staleness: {} SECONDS", stale);
            }
            if (stale >= requestCacheControl.getMaxStale()) {
                LOG.debug("Response from cache is not suitable due to the request max-stale requirement");
                return CacheSuitability.REVALIDATION_REQUIRED;
            }
            LOG.debug("The cache entry is fresh enough");
            return CacheSuitability.FRESH_ENOUGH;
        }

        if (fresh) {
            LOG.debug("The cache entry is fresh");
            return CacheSuitability.FRESH;
        }
        if (responseCacheControl.getStaleWhileRevalidate() > 0) {
            final long stale = currentAge.compareTo(freshnessLifetime) > 0 ? currentAge.toSeconds() - freshnessLifetime.toSeconds() : 0;
            if (stale < responseCacheControl.getStaleWhileRevalidate()) {
                LOG.debug("The cache entry is stale but suitable while being revalidated");
                return CacheSuitability.STALE_WHILE_REVALIDATED;
            }
        }
        LOG.debug("The cache entry is stale");
        return CacheSuitability.STALE;
    }
Determine if I can utilize the given {@link HttpCacheEntry} to respond to the given
{@link HttpRequest}.

@since 5.4
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedResponseSuitabilityChecker.java