TimeValue getHeuristicFreshnessLifetime(final HttpCacheEntry entry) {
        final Instant dateValue = entry.getInstant();
        final Instant lastModifiedValue = entry.getLastModified();

        if (dateValue != null && lastModifiedValue != null) {
            final Duration diff = Duration.between(lastModifiedValue, dateValue);

            if (diff.isNegative()) {
                return TimeValue.ZERO_MILLISECONDS;
            }
            return TimeValue.ofSeconds((long) (heuristicCoefficient * diff.getSeconds()));
        }

        return heuristicDefaultLifetime;
    }
Calculate the freshness lifetime of a response based on the provided cache control and cache entry.
<ul>
<li>If the cache is shared and the s-maxage response directive is present, use its value.</li>
<li>If the max-age response directive is present, use its value.</li>
<li>If the Expires response header field is present, use its value minus the value of the Date response header field.</li>
<li>Otherwise, a heuristic freshness lifetime might be applicable.</li>
</ul>

@param responseCacheControl the cache control directives associated with the response.
@param entry                the cache entry associated with the response.
@return the calculated freshness lifetime as a {@link TimeValue}.
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheValidityPolicy.java