You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2023/11/16 19:04:37 UTC

(httpcomponents-client) 03/08: HTTPCLIENT-2277: Aligned ResponseCachingPolicy with the specification requirements per RFC 9111 section 3

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch 5.4.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git

commit 7ea2ecb4d31e892a56ddf728a45b137bbb1642a7
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Sun Oct 22 12:07:31 2023 +0200

    HTTPCLIENT-2277: Aligned ResponseCachingPolicy with the specification requirements per RFC 9111 section 3
---
 .../client5/http/impl/cache/AsyncCachingExec.java  |   5 +
 .../hc/client5/http/impl/cache/CachingExec.java    |   4 +
 .../client5/http/impl/cache/CachingExecBase.java   |  14 +-
 .../http/impl/cache/ResponseCachingPolicy.java     | 220 +++++++-------
 .../http/impl/cache/TestResponseCachingPolicy.java | 333 +++++++--------------
 5 files changed, 232 insertions(+), 344 deletions(-)

diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
index 5608bbfba..f30eeff1f 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
@@ -462,6 +462,11 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
                 }
 
             });
+            if (isResponseTooBig(entityDetails)) {
+                LOG.debug("Backend response is known to be too big");
+                return asyncExecCallback.handleResponse(backendResponse, entityDetails);
+            }
+
             final ResponseCacheControl responseCacheControl = CacheControlHeaderParser.INSTANCE.parse(backendResponse);
             final boolean cacheable = responseCachingPolicy.isResponseCacheable(responseCacheControl, request, backendResponse);
             if (cacheable) {
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
index 30467ed20..6311d8865 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
@@ -368,6 +368,10 @@ class CachingExec extends CachingExecBase implements ExecChainHandler {
             final ClassicHttpResponse backendResponse) throws IOException {
 
         responseCache.evictInvalidatedEntries(target, request, backendResponse);
+        if (isResponseTooBig(backendResponse.getEntity())) {
+            LOG.debug("Backend response is known to be too big");
+            return backendResponse;
+        }
         final ResponseCacheControl responseCacheControl = CacheControlHeaderParser.INSTANCE.parse(backendResponse);
         final boolean cacheable = responseCachingPolicy.isResponseCacheable(responseCacheControl, request, backendResponse);
         if (cacheable) {
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
index 4c7f09b71..81bb1e4c3 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
@@ -35,6 +35,7 @@ import org.apache.hc.client5.http.cache.CacheResponseStatus;
 import org.apache.hc.client5.http.cache.HttpCacheContext;
 import org.apache.hc.client5.http.cache.HttpCacheEntry;
 import org.apache.hc.client5.http.cache.ResourceIOException;
+import org.apache.hc.core5.http.EntityDetails;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpHeaders;
 import org.apache.hc.core5.http.HttpHost;
@@ -85,7 +86,6 @@ public class CachingExecBase {
         this.cacheableRequestPolicy = new CacheableRequestPolicy();
         this.suitabilityChecker = new CachedResponseSuitabilityChecker(this.validityPolicy, this.cacheConfig);
         this.responseCachingPolicy = new ResponseCachingPolicy(
-                this.cacheConfig.getMaxObjectSize(),
                 this.cacheConfig.isSharedCache(),
                 this.cacheConfig.isNeverCacheHTTP10ResponsesWithQuery(),
                 this.cacheConfig.isNeverCacheHTTP11ResponsesWithQuery(),
@@ -282,4 +282,16 @@ public class CachingExecBase {
         }
     }
 
+    boolean isResponseTooBig(final EntityDetails entityDetails) {
+        if (entityDetails == null) {
+            return false;
+        }
+        final long contentLength = entityDetails.getContentLength();
+        if (contentLength == -1) {
+            return false;
+        }
+        final long maxObjectSize = cacheConfig.getMaxObjectSize();
+        return contentLength > maxObjectSize;
+    }
+
 }
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java
index cf3e83611..47472f06d 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java
@@ -33,8 +33,6 @@ import java.util.Set;
 
 import org.apache.hc.client5.http.cache.HttpCacheEntry;
 import org.apache.hc.client5.http.utils.DateUtils;
-import org.apache.hc.core5.http.Header;
-import org.apache.hc.core5.http.HeaderElement;
 import org.apache.hc.core5.http.HttpHeaders;
 import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.HttpResponse;
@@ -43,7 +41,6 @@ import org.apache.hc.core5.http.HttpVersion;
 import org.apache.hc.core5.http.Method;
 import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.message.BasicTokenIterator;
-import org.apache.hc.core5.http.message.MessageSupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -63,7 +60,6 @@ class ResponseCachingPolicy {
 
     private static final Logger LOG = LoggerFactory.getLogger(ResponseCachingPolicy.class);
 
-    private final long maxObjectSizeBytes;
     private final boolean sharedCache;
     private final boolean neverCache1_0ResponsesWithQueryString;
     private final boolean neverCache1_1ResponsesWithQueryString;
@@ -79,8 +75,6 @@ class ResponseCachingPolicy {
     /**
      * Constructs a new ResponseCachingPolicy with the specified cache policy settings and stale-if-error support.
      *
-     * @param maxObjectSizeBytes                    the maximum size of objects, in bytes, that should be stored
-     *                                              in the cache
      * @param sharedCache                           whether to behave as a shared cache (true) or a
      *                                              non-shared/private cache (false)
      * @param neverCache1_0ResponsesWithQueryString {@code true} to never cache HTTP 1.0 responses with a query string,
@@ -92,110 +86,117 @@ class ResponseCachingPolicy {
      *                                              results in an error, {@code false} to disable this feature.
      * @since 5.3
      */
-    public ResponseCachingPolicy(final long maxObjectSizeBytes,
+    public ResponseCachingPolicy(
              final boolean sharedCache,
              final boolean neverCache1_0ResponsesWithQueryString,
              final boolean neverCache1_1ResponsesWithQueryString,
              final boolean staleIfErrorEnabled) {
-        this.maxObjectSizeBytes = maxObjectSizeBytes;
         this.sharedCache = sharedCache;
         this.neverCache1_0ResponsesWithQueryString = neverCache1_0ResponsesWithQueryString;
         this.neverCache1_1ResponsesWithQueryString = neverCache1_1ResponsesWithQueryString;
         this.staleIfErrorEnabled = staleIfErrorEnabled;
     }
 
-    boolean isResponseCacheable(final ResponseCacheControl cacheControl, final String httpMethod, final HttpResponse response) {
-        if (response.countHeaders(HttpHeaders.EXPIRES) > 1) {
-            LOG.debug("Multiple Expires headers");
+    /**
+     * Determine if the {@link HttpResponse} gotten from the origin is a
+     * cacheable response.
+     *
+     * @return {@code true} if response is cacheable
+     */
+    public boolean isResponseCacheable(final ResponseCacheControl cacheControl, final HttpRequest request, final HttpResponse response) {
+        final ProtocolVersion version = request.getVersion() != null ? request.getVersion() : HttpVersion.DEFAULT;
+        if (version.compareToVersion(HttpVersion.HTTP_1_1) > 0) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Protocol version {} is non-cacheable", version);
+            }
             return false;
         }
 
-        if (response.countHeaders(HttpHeaders.DATE) > 1) {
-            LOG.debug("Multiple Date headers");
+        // Presently only GET and HEAD methods are supported
+        final String httpMethod = request.getMethod();
+        if (!Method.GET.isSame(httpMethod) && !Method.HEAD.isSame(httpMethod)) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("{} method response is not cacheable", httpMethod);
+            }
             return false;
         }
 
-        final Instant responseDate = DateUtils.parseStandardDate(response, HttpHeaders.DATE);
-        final Instant responseExpires = DateUtils.parseStandardDate(response, HttpHeaders.EXPIRES);
+        final int code = response.getCode();
 
-        if (expiresHeaderLessOrEqualToDateHeaderAndNoCacheControl(cacheControl,  responseDate, responseExpires)) {
-            LOG.debug("Expires header less or equal to Date header and no cache control directives");
+        // Should never happen but better be defensive
+        if (code <= HttpStatus.SC_INFORMATIONAL) {
             return false;
         }
 
-        boolean cacheable = false;
-
-        if (!Method.GET.isSame(httpMethod) && !Method.HEAD.isSame(httpMethod) && !Method.POST.isSame((httpMethod))) {
+        if (isKnownNonCacheableStatusCode(code)) {
             if (LOG.isDebugEnabled()) {
-                LOG.debug("{} method response is not cacheable", httpMethod);
+                LOG.debug("{} response is not cacheable", code);
             }
             return false;
         }
 
-        final int status = response.getCode();
-        if (isKnownCacheableStatusCode(status)) {
-            // these response codes MAY be cached
-            cacheable = true;
-        } else if (isKnownNonCacheableStatusCode(status)) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("{} response is not cacheable", status);
+        if (request.getPath().contains("?")) {
+            if (neverCache1_0ResponsesWithQueryString && from1_0Origin(response)) {
+                LOG.debug("Response is not cacheable as it had a query string");
+                return false;
+            } else if (!neverCache1_1ResponsesWithQueryString && !isExplicitlyCacheable(cacheControl, response)) {
+                LOG.debug("Response is not cacheable as it is missing explicit caching headers");
+                return false;
             }
+        }
+
+        if (cacheControl.isMustUnderstand() && !understoodStatusCode(code)) {
+            // must-understand cache directive overrides no-store
+            LOG.debug("Response contains a status code that the cache does not understand, so it's not cacheable");
             return false;
-        } else if (isUnknownStatusCode(status)) {
-            // a response with an unknown status code MUST NOT be
-            // cached
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("{} response is unknown", status);
-            }
+        }
+
+        if (isExplicitlyNonCacheable(cacheControl)) {
+            LOG.debug("Response is explicitly non-cacheable per cache control directive");
             return false;
         }
 
-        final Header contentLength = response.getFirstHeader(HttpHeaders.CONTENT_LENGTH);
-        if (contentLength != null) {
-            final long contentLengthValue = Long.parseLong(contentLength.getValue());
-            if (contentLengthValue > this.maxObjectSizeBytes) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Response content length exceeds {}", this.maxObjectSizeBytes);
-                }
+        if (sharedCache) {
+            if (request.containsHeader(HttpHeaders.AUTHORIZATION) &&
+                    cacheControl.getSharedMaxAge() == -1 &&
+                    !cacheControl.isPublic()) {
+                LOG.debug("Request contains private credentials");
                 return false;
             }
         }
 
-        final Iterator<HeaderElement> it = MessageSupport.iterate(response, HttpHeaders.VARY);
-        while (it.hasNext()) {
-            final HeaderElement elem = it.next();
-            if ("*".equals(elem.getName())) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Vary * found");
-                }
-                return false;
-            }
+        // See if the response is tainted
+        if (response.countHeaders(HttpHeaders.EXPIRES) > 1) {
+            LOG.debug("Multiple Expires headers");
+            return false;
         }
-        if (isExplicitlyNonCacheable(cacheControl)) {
-            LOG.debug("Response is explicitly non-cacheable");
+
+        if (response.countHeaders(HttpHeaders.DATE) > 1) {
+            LOG.debug("Multiple Date headers");
             return false;
         }
 
-        final Duration freshnessLifetime = calculateFreshnessLifetime(cacheControl, responseDate, responseExpires);
+        final Instant responseDate = DateUtils.parseStandardDate(response, HttpHeaders.DATE);
+        final Instant responseExpires = DateUtils.parseStandardDate(response, HttpHeaders.EXPIRES);
 
-        // If the 'immutable' directive is present and the response is still fresh,
-        // then the response is considered cacheable without further validation
-        if (cacheControl.isImmutable() && responseIsStillFresh(responseDate, freshnessLifetime)) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Response is immutable and fresh, considered cacheable without further validation");
-            }
-            return true;
+        if (expiresHeaderLessOrEqualToDateHeaderAndNoCacheControl(cacheControl, responseDate, responseExpires)) {
+            LOG.debug("Expires header less or equal to Date header and no cache control directives");
+            return false;
         }
 
-        // calculate freshness lifetime
-        if (freshnessLifetime.isNegative() || freshnessLifetime.isZero()) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Freshness lifetime is invalid");
+        // Treat responses with `Vary: *` as essentially non-cacheable.
+        final Iterator<String> it = new BasicTokenIterator(response.headerIterator(HttpHeaders.VARY));
+        while (it.hasNext()) {
+            final String token = it.next();
+            if ("*".equals(token)) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Vary: * found");
+                }
+                return false;
             }
-            return false;
         }
 
-        return cacheable || isExplicitlyCacheable(cacheControl, response);
+        return isExplicitlyCacheable(cacheControl, response) || isHeuristicallyCacheable(cacheControl, code, responseDate, responseExpires);
     }
 
     private static boolean isKnownCacheableStatusCode(final int status) {
@@ -253,60 +254,57 @@ class ResponseCachingPolicy {
     }
 
     protected boolean isExplicitlyCacheable(final ResponseCacheControl cacheControl, final HttpResponse response) {
-        if (response.containsHeader(HttpHeaders.EXPIRES)) {
+        if (cacheControl.isPublic()) {
             return true;
         }
-        return cacheControl.getMaxAge() > 0 || cacheControl.getSharedMaxAge()>0 ||
-                cacheControl.isMustRevalidate() || cacheControl.isProxyRevalidate() || (cacheControl.isPublic());
-    }
-
-    /**
-     * Determine if the {@link HttpResponse} gotten from the origin is a
-     * cacheable response.
-     *
-     * @return {@code true} if response is cacheable
-     */
-    public boolean isResponseCacheable(final ResponseCacheControl cacheControl, final HttpRequest request, final HttpResponse response) {
-        final ProtocolVersion version = request.getVersion() != null ? request.getVersion() : HttpVersion.DEFAULT;
-        if (version.compareToVersion(HttpVersion.HTTP_1_1) > 0) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Protocol version {} is non-cacheable", version);
-            }
-            return false;
+        if (!sharedCache && cacheControl.isCachePrivate()) {
+            return true;
         }
-
-        if (cacheControl.isMustUnderstand() && cacheControl.isNoStore() && !understoodStatusCode(response.getCode())) {
-            // must-understand cache directive overrides no-store
-            LOG.debug("Response contains a status code that the cache does not understand, so it's not cacheable");
-            return false;
+        if (response.containsHeader(HttpHeaders.EXPIRES)) {
+            return true;
         }
-
-        if (!cacheControl.isMustUnderstand() && cacheControl.isNoStore()) {
-            LOG.debug("Response is explicitly non-cacheable per cache control directive");
-            return false;
+        if (cacheControl.getMaxAge() > 0) {
+            return true;
         }
-
-
-        if (request.getRequestUri().contains("?")) {
-            if (neverCache1_0ResponsesWithQueryString && from1_0Origin(response)) {
-                LOG.debug("Response is not cacheable as it had a query string");
-                return false;
-            } else if (!neverCache1_1ResponsesWithQueryString && !isExplicitlyCacheable(cacheControl, response)) {
-                LOG.debug("Response is not cacheable as it is missing explicit caching headers");
-                return false;
-            }
+        if (sharedCache && cacheControl.getSharedMaxAge() > 0) {
+            return true;
         }
+        return false;
+    }
 
-        if (sharedCache) {
-            if (request.countHeaders(HttpHeaders.AUTHORIZATION) > 0
-                    && !(cacheControl.getSharedMaxAge() > -1 || cacheControl.isMustRevalidate() || cacheControl.isPublic())) {
-                LOG.debug("Request contains private credentials");
+    protected boolean isHeuristicallyCacheable(final ResponseCacheControl cacheControl,
+                                               final int status,
+                                               final Instant responseDate,
+                                               final Instant responseExpires) {
+        if (isKnownCacheableStatusCode(status)) {
+            final Duration freshnessLifetime = calculateFreshnessLifetime(cacheControl, responseDate, responseExpires);
+            // calculate freshness lifetime
+            if (freshnessLifetime.isNegative()) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Freshness lifetime is invalid");
+                }
                 return false;
             }
+            // If the 'immutable' directive is present and the response is still fresh,
+            // then the response is considered cacheable without further validation
+            if (cacheControl.isImmutable() && responseIsStillFresh(responseDate, freshnessLifetime)) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Response is immutable and fresh, considered cacheable without further validation");
+                }
+                return true;
+            }
+            if (freshnessLifetime.compareTo(Duration.ZERO) > 0) {
+                return true;
+            }
+        } else if (isUnknownStatusCode(status)) {
+            // a response with an unknown status code MUST NOT be
+            // cached
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("{} response is unknown", status);
+            }
+            return false;
         }
-
-        final String method = request.getMethod();
-        return isResponseCacheable(cacheControl, method, response);
+        return false;
     }
 
     private boolean expiresHeaderLessOrEqualToDateHeaderAndNoCacheControl(final ResponseCacheControl cacheControl, final Instant responseDate, final Instant expires) {
@@ -316,7 +314,7 @@ class ResponseCachingPolicy {
         if (expires == null || responseDate == null) {
             return false;
         }
-        return expires.equals(responseDate) || expires.isBefore(responseDate);
+        return expires.compareTo(responseDate) <= 0;
     }
 
     private boolean from1_0Origin(final HttpResponse response) {
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCachingPolicy.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCachingPolicy.java
index 570900a7b..9215e5c18 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCachingPolicy.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCachingPolicy.java
@@ -42,6 +42,7 @@ import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpStatus;
 import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.Method;
 import org.apache.hc.core5.http.message.BasicHttpRequest;
 import org.apache.hc.core5.http.message.BasicHttpResponse;
 import org.junit.jupiter.api.Assertions;
@@ -67,7 +68,7 @@ public class TestResponseCachingPolicy {
         sixSecondsAgo = now.minusSeconds(6);
         tenSecondsFromNow = now.plusSeconds(10);
 
-        policy = new ResponseCachingPolicy(0, true, false, false, false);
+        policy = new ResponseCachingPolicy(true, false, false, false);
         request = new BasicHttpRequest("GET","/");
         response = new BasicHttpResponse(HttpStatus.SC_OK, "");
         response.setHeader("Date", DateUtils.formatStandardDate(Instant.now()));
@@ -76,14 +77,26 @@ public class TestResponseCachingPolicy {
     }
 
     @Test
-    public void testIsGetCacheable() {
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+    public void testGetCacheable() {
+        policy = new ResponseCachingPolicy(true, false, false, true);
+        request = new BasicHttpRequest(Method.GET, "/");
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
+    }
+
+    @Test
+    public void testHeadCacheable() {
+        policy = new ResponseCachingPolicy(true, false, false, true);
+        request = new BasicHttpRequest(Method.HEAD, "/");
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
-    public void testIsHeadCacheable() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "HEAD", response));
+    public void testArbitraryMethodNotCacheable() {
+        request = new BasicHttpRequest("PUT", "/");
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
+
+        request = new BasicHttpRequest("huh", "/");
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
@@ -95,7 +108,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void testResponsesToRequestsWithAuthorizationHeadersAreCacheableByNonSharedCache() {
-        policy = new ResponseCachingPolicy(0, false, false, false, true);
+        policy = new ResponseCachingPolicy(false, false, false, true);
         request = new BasicHttpRequest("GET","/");
         request.setHeader("Authorization", StandardAuthScheme.BASIC + " dXNlcjpwYXNzd2Q=");
         Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
@@ -112,16 +125,6 @@ public class TestResponseCachingPolicy {
         Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
-    @Test
-    public void testAuthorizedResponsesWithMustRevalidateAreCacheable() {
-        request = new BasicHttpRequest("GET","/");
-        request.setHeader("Authorization", StandardAuthScheme.BASIC + " dXNlcjpwYXNzd2Q=");
-        responseCacheControl = ResponseCacheControl.builder()
-                .setMustRevalidate(true)
-                .build();
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
-    }
-
     @Test
     public void testAuthorizedResponsesWithCacheControlPublicAreCacheable() {
         request = new BasicHttpRequest("GET","/");
@@ -145,65 +148,53 @@ public class TestResponseCachingPolicy {
     @Test
     public void test203ResponseCodeIsCacheable() {
         response.setCode(HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION);
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void test206ResponseCodeIsNotCacheable() {
         response.setCode(HttpStatus.SC_PARTIAL_CONTENT);
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
-    }
-
-    @Test
-    public void test206ResponseCodeIsNotCacheableUsingSharedPublicCache() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
-
-        request.setHeader("Authorization", StandardAuthScheme.BASIC + " QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
-        response.setCode(HttpStatus.SC_PARTIAL_CONTENT);
-        responseCacheControl = ResponseCacheControl.builder()
-                .setCachePublic(true)
-                .build();
         Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void test300ResponseCodeIsCacheable() {
         response.setCode(HttpStatus.SC_MULTIPLE_CHOICES);
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void test301ResponseCodeIsCacheable() {
         response.setCode(HttpStatus.SC_MOVED_PERMANENTLY);
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void test410ResponseCodeIsCacheable() {
         response.setCode(HttpStatus.SC_GONE);
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void testPlain302ResponseCodeIsNotCacheable() {
         response.setCode(HttpStatus.SC_MOVED_TEMPORARILY);
         response.removeHeaders("Expires");
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void testPlain303ResponseCodeIsNotCacheableUnderDefaultBehavior() {
         response.setCode(HttpStatus.SC_SEE_OTHER);
         response.removeHeaders("Expires");
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void testPlain303ResponseCodeIsNotCacheableEvenIf303CachingEnabled() {
-        policy = new ResponseCachingPolicy(0, true, false, true, true);
+        policy = new ResponseCachingPolicy(true, false, true, true);
         response.setCode(HttpStatus.SC_SEE_OTHER);
         response.removeHeaders("Expires");
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
 
@@ -211,7 +202,7 @@ public class TestResponseCachingPolicy {
     public void testPlain307ResponseCodeIsNotCacheable() {
         response.setCode(HttpStatus.SC_TEMPORARY_REDIRECT);
         response.removeHeaders("Expires");
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
@@ -219,7 +210,7 @@ public class TestResponseCachingPolicy {
         final int status = getRandomStatus();
         response.setCode(status);
         response.setHeader("Expires", DateUtils.formatStandardDate(Instant.now().plus(1, ChronoUnit.HOURS)));
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
@@ -229,7 +220,7 @@ public class TestResponseCachingPolicy {
         responseCacheControl = ResponseCacheControl.builder()
                 .setMaxAge(0)
                 .build();
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
@@ -237,7 +228,7 @@ public class TestResponseCachingPolicy {
         final int status = getRandomStatus();
         response.setCode(status);
         response.removeHeaders(HttpHeaders.CACHE_CONTROL);
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
@@ -247,7 +238,7 @@ public class TestResponseCachingPolicy {
         responseCacheControl = ResponseCacheControl.builder()
                 .setSharedMaxAge(1)
                 .build();
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
@@ -257,7 +248,7 @@ public class TestResponseCachingPolicy {
         responseCacheControl = ResponseCacheControl.builder()
                 .setMustRevalidate(true)
                 .build();
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
@@ -267,7 +258,7 @@ public class TestResponseCachingPolicy {
         responseCacheControl = ResponseCacheControl.builder()
                 .setProxyRevalidate(true)
                 .build();
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
@@ -277,7 +268,7 @@ public class TestResponseCachingPolicy {
         responseCacheControl = ResponseCacheControl.builder()
                 .setCachePublic(true)
                 .build();
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
@@ -287,164 +278,86 @@ public class TestResponseCachingPolicy {
         responseCacheControl = ResponseCacheControl.builder()
                 .setCachePrivate(true)
                 .build();
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void test200ResponseWithPrivateCacheControlIsCacheableByNonSharedCache() {
-        policy = new ResponseCachingPolicy(0, false, false, false, true);
+        policy = new ResponseCachingPolicy(false, false, false, true);
         response.setCode(HttpStatus.SC_OK);
         responseCacheControl = ResponseCacheControl.builder()
                 .setCachePrivate(true)
                 .build();
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
-    }
-
-    @Test
-    public void testIsGetWithNoCacheCacheable() {
-        responseCacheControl = ResponseCacheControl.builder()
-                .setNoCache(true)
-                .build();
-
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
-    public void testIsHeadWithNoCacheCacheable() {
+    public void testControlNoCacheCacheable() {
         responseCacheControl = ResponseCacheControl.builder()
                 .setNoCache(true)
                 .build();
 
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "HEAD", response));
-    }
-
-    @Test
-    public void testIsGetWithNoStoreCacheable() {
-        responseCacheControl = ResponseCacheControl.builder()
-                .setNoStore(true)
-                .build();
-
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
-    }
-
-    @Test
-    public void testIsHeadWithNoStoreCacheable() {
-        responseCacheControl = ResponseCacheControl.builder()
-                .setNoStore(true)
-                .build();
-
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "HEAD", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
-    public void testIsGetWithNoStoreEmbeddedInListCacheable() {
+    public void testControlNoStoreNotCacheable() {
         responseCacheControl = ResponseCacheControl.builder()
-                .setCachePublic(true)
                 .setNoStore(true)
                 .build();
 
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
-    public void testIsHeadWithNoStoreEmbeddedInListCacheable() {
+    public void testControlNoStoreEmbeddedInListCacheable() {
         responseCacheControl = ResponseCacheControl.builder()
                 .setCachePublic(true)
                 .setNoStore(true)
                 .build();
 
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "HEAD", response));
-    }
-
-    @Test
-    public void testIsGetWithNoCacheEmbeddedInListCacheable() {
-        responseCacheControl = ResponseCacheControl.builder()
-                .setCachePublic(true)
-                .setNoCache(true)
-                .build();
-
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
-    }
-
-    @Test
-    public void testIsHeadWithNoCacheEmbeddedInListCacheable() {
-        responseCacheControl = ResponseCacheControl.builder()
-                .setCachePublic(true)
-                .setNoCache(true)
-                .build();
-
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "HEAD", response));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
-    public void testIsGetWithNoCacheEmbeddedInListAfterFirstHeaderCacheable() {
+    public void testControlNoCacheEmbeddedInListCacheable() {
         responseCacheControl = ResponseCacheControl.builder()
-                .setMaxAge(20)
                 .setCachePublic(true)
                 .setNoCache(true)
                 .build();
 
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
-    public void testIsHeadWithNoCacheEmbeddedInListAfterFirstHeaderCacheable() {
+    public void testControlNoCacheEmbeddedInListAfterFirstHeaderCacheable() {
         responseCacheControl = ResponseCacheControl.builder()
                 .setMaxAge(20)
                 .setCachePublic(true)
                 .setNoCache(true)
                 .build();
 
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "HEAD", response));
-    }
-
-    @Test
-    public void testIsGetWithNoStoreEmbeddedInListAfterFirstHeaderCacheable() {
-        responseCacheControl = ResponseCacheControl.builder()
-                .setMaxAge(20)
-                .setCachePublic(true)
-                .setNoStore(true)
-                .build();
-
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
-    public void testIsHeadWithNoStoreEmbeddedInListAfterFirstHeaderCacheable() {
+    public void testControlNoStoreEmbeddedInListAfterFirstHeaderCacheable() {
         responseCacheControl = ResponseCacheControl.builder()
                 .setMaxAge(20)
                 .setCachePublic(true)
                 .setNoStore(true)
                 .build();
 
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "HEAD", response));
-    }
-
-    @Test
-    public void testIsGetWithAnyCacheControlCacheable() {
-        responseCacheControl = ResponseCacheControl.builder()
-                .setMaxAge(10)
-                .build();
-
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
-
-        response = new BasicHttpResponse(HttpStatus.SC_OK, "");
-        response.setHeader("Date", DateUtils.formatStandardDate(Instant.now()));
-        response.setHeader("Content-Length", "0");
-        responseCacheControl = ResponseCacheControl.builder()
-                .build();
-
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
-    public void testIsHeadWithAnyCacheControlCacheable() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
+    public void testControlAnyCacheControlCacheable() {
         responseCacheControl = ResponseCacheControl.builder()
                 .setMaxAge(10)
                 .build();
 
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "HEAD", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
 
         response = new BasicHttpResponse(HttpStatus.SC_OK, "");
         response.setHeader("Date", DateUtils.formatStandardDate(Instant.now()));
@@ -452,40 +365,29 @@ public class TestResponseCachingPolicy {
         responseCacheControl = ResponseCacheControl.builder()
                 .build();
 
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "HEAD", response));
-    }
-
-    @Test
-    public void testIsGetWithout200Cacheable() {
-        HttpResponse response404 = new BasicHttpResponse(HttpStatus.SC_NOT_FOUND, "");
-
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response404));
-
-        response404 = new BasicHttpResponse(HttpStatus.SC_GATEWAY_TIMEOUT, "");
-
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response404));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
-    public void testIsHeadWithout200Cacheable() {
+    public void testControlWithout200Cacheable() {
         HttpResponse response404 = new BasicHttpResponse(HttpStatus.SC_NOT_FOUND, "");
 
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "HEAD", response404));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response404));
 
         response404 = new BasicHttpResponse(HttpStatus.SC_GATEWAY_TIMEOUT, "");
 
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "HEAD", response404));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response404));
     }
 
     @Test
     public void testVaryStarIsNotCacheable() {
         response.setHeader("Vary", "*");
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void testVaryStarIsNotCacheableUsingSharedPublicCache() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
+        policy = new ResponseCachingPolicy(true, false, false, true);
 
         request.setHeader("Authorization", StandardAuthScheme.BASIC + " QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
         response.setHeader("Vary", "*");
@@ -496,29 +398,14 @@ public class TestResponseCachingPolicy {
     }
 
     @Test
-    public void testIsGetWithVaryHeaderCacheable() {
-        response.addHeader("Vary", "Accept-Encoding");
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
-    }
-
-    @Test
-    public void testIsHeadWithVaryHeaderCacheable() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
+    public void testRequestWithVaryHeaderCacheable() {
         response.addHeader("Vary", "Accept-Encoding");
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "HEAD", response));
-    }
-
-    @Test
-    public void testIsArbitraryMethodCacheable() {
-
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "PUT", response));
-
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "huh", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void testIsArbitraryMethodCacheableUsingSharedPublicCache() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
+        policy = new ResponseCachingPolicy(true, false, false, true);
 
         request = new HttpOptions("http://foo.example.com/");
         request.setHeader("Authorization", StandardAuthScheme.BASIC + " QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
@@ -534,12 +421,12 @@ public class TestResponseCachingPolicy {
     public void testResponsesWithMultipleAgeHeadersAreCacheable() {
         response.addHeader("Age", "3");
         response.addHeader("Age", "5");
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void testResponsesWithMultipleAgeHeadersAreNotCacheableUsingSharedPublicCache() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
+        policy = new ResponseCachingPolicy(true, false, false, true);
 
         request.setHeader("Authorization", StandardAuthScheme.BASIC + " QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
         response.addHeader("Age", "3");
@@ -554,12 +441,12 @@ public class TestResponseCachingPolicy {
     public void testResponsesWithMultipleDateHeadersAreNotCacheable() {
         response.addHeader("Date", DateUtils.formatStandardDate(now));
         response.addHeader("Date", DateUtils.formatStandardDate(sixSecondsAgo));
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void testResponsesWithMultipleDateHeadersAreNotCacheableUsingSharedPublicCache() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
+        policy = new ResponseCachingPolicy(true, false, false, true);
 
         request.setHeader("Authorization", StandardAuthScheme.BASIC + " QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
         response.addHeader("Date", DateUtils.formatStandardDate(now));
@@ -573,12 +460,12 @@ public class TestResponseCachingPolicy {
     @Test
     public void testResponsesWithMalformedDateHeadersAreNotCacheable() {
         response.addHeader("Date", "garbage");
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void testResponsesWithMalformedDateHeadersAreNotCacheableUsingSharedPublicCache() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
+        policy = new ResponseCachingPolicy(true, false, false, true);
 
         request.setHeader("Authorization", StandardAuthScheme.BASIC + " QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
         response.addHeader("Date", "garbage");
@@ -592,12 +479,12 @@ public class TestResponseCachingPolicy {
     public void testResponsesWithMultipleExpiresHeadersAreNotCacheable() {
         response.addHeader("Expires", DateUtils.formatStandardDate(now));
         response.addHeader("Expires", DateUtils.formatStandardDate(sixSecondsAgo));
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void testResponsesWithMultipleExpiresHeadersAreNotCacheableUsingSharedPublicCache() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
+        policy = new ResponseCachingPolicy(true, false, false, true);
 
         request.setHeader("Authorization", StandardAuthScheme.BASIC + " QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
         response.addHeader("Expires", DateUtils.formatStandardDate(now));
@@ -608,28 +495,10 @@ public class TestResponseCachingPolicy {
         Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
-    @Test
-    public void testResponseThatHasTooMuchContentIsNotCacheable() {
-        response.setHeader("Content-Length", "9000");
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, "GET", response));
-    }
-
-    @Test
-    public void testResponseThatHasTooMuchContentIsNotCacheableUsingSharedPublicCache() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
-
-        request.setHeader("Authorization", StandardAuthScheme.BASIC + " QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
-        response.setHeader("Content-Length", "9000");
-        responseCacheControl = ResponseCacheControl.builder()
-                .setCachePublic(true)
-                .build();
-        Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
-    }
-
     @Test
     public void testResponsesThatAreSmallEnoughAreCacheable() {
         response.setHeader("Content-Length", "0");
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
@@ -646,14 +515,14 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void testResponsesToGETWithQueryParamsButNoExplicitCachingAreNotCacheableEvenWhen1_0QueryCachingDisabled() {
-        policy = new ResponseCachingPolicy(0, true, true, false, false);
+        policy = new ResponseCachingPolicy(true, true, false, false);
         request = new BasicHttpRequest("GET", "/foo?s=bar");
         Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
     @Test
     public void testResponsesToHEADWithQueryParamsButNoExplicitCachingAreNotCacheableEvenWhen1_0QueryCachingDisabled() {
-        policy = new ResponseCachingPolicy(0, true, true, false, false);
+        policy = new ResponseCachingPolicy(true, true, false, false);
         request = new BasicHttpRequest("HEAD", "/foo?s=bar");
         Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response));
     }
@@ -668,7 +537,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void testResponsesToHEADWithQueryParamsAndExplicitCachingAreCacheable() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
+        policy = new ResponseCachingPolicy(true, false, false, true);
         request = new BasicHttpRequest("HEAD", "/foo?s=bar");
         response.setHeader("Date", DateUtils.formatStandardDate(now));
         response.setHeader("Expires", DateUtils.formatStandardDate(tenSecondsFromNow));
@@ -677,7 +546,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void testResponsesToGETWithQueryParamsAndExplicitCachingAreCacheableEvenWhen1_0QueryCachingDisabled() {
-        policy = new ResponseCachingPolicy(0, true, true, false, true);
+        policy = new ResponseCachingPolicy(true, true, false, true);
         request = new BasicHttpRequest("GET", "/foo?s=bar");
         response.setHeader("Date", DateUtils.formatStandardDate(now));
         response.setHeader("Expires", DateUtils.formatStandardDate(tenSecondsFromNow));
@@ -686,7 +555,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void testResponsesToHEADWithQueryParamsAndExplicitCachingAreCacheableEvenWhen1_0QueryCachingDisabled() {
-        policy = new ResponseCachingPolicy(0, true, true, false, true);
+        policy = new ResponseCachingPolicy(true, true, false, true);
         request = new BasicHttpRequest("HEAD", "/foo?s=bar");
         response.setHeader("Date", DateUtils.formatStandardDate(now));
         response.setHeader("Expires", DateUtils.formatStandardDate(tenSecondsFromNow));
@@ -711,7 +580,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void getsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheableEvenWithSetting() {
-        policy = new ResponseCachingPolicy(0, true, true, false, true);
+        policy = new ResponseCachingPolicy(true, true, false, true);
         request = new BasicHttpRequest("GET", "/foo?s=bar");
         response = new BasicHttpResponse(HttpStatus.SC_OK, "OK");
         response.setVersion(HttpVersion.HTTP_1_0);
@@ -720,7 +589,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void headsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheableEvenWithSetting() {
-        policy = new ResponseCachingPolicy(0, true, true, false, true);
+        policy = new ResponseCachingPolicy(true, true, false, true);
         request = new BasicHttpRequest("HEAD", "/foo?s=bar");
         response = new BasicHttpResponse(HttpStatus.SC_OK, "OK");
         response.setVersion(HttpVersion.HTTP_1_0);
@@ -739,7 +608,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void headsWithQueryParametersDirectlyFrom1_0OriginsAreCacheableWithExpires() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
+        policy = new ResponseCachingPolicy(true, false, false, true);
         request = new BasicHttpRequest("HEAD", "/foo?s=bar");
         response = new BasicHttpResponse(HttpStatus.SC_OK, "OK");
         response.setVersion(HttpVersion.HTTP_1_0);
@@ -750,7 +619,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void getsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenWithExpires() {
-        policy = new ResponseCachingPolicy(0, true, true, false, true);
+        policy = new ResponseCachingPolicy(true, true, false, true);
         request = new BasicHttpRequest("GET", "/foo?s=bar");
         response = new BasicHttpResponse(HttpStatus.SC_OK, "OK");
         response.setVersion(HttpVersion.HTTP_1_0);
@@ -761,7 +630,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void headsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenWithExpires() {
-        policy = new ResponseCachingPolicy(0, true, true, false, true);
+        policy = new ResponseCachingPolicy(true, true, false, true);
         request = new BasicHttpRequest("HEAD", "/foo?s=bar");
         response = new BasicHttpResponse(HttpStatus.SC_OK, "OK");
         response.setVersion(HttpVersion.HTTP_1_0);
@@ -795,7 +664,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void headsWithQueryParametersFrom1_0OriginsViaProxiesAreCacheableWithExpires() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
+        policy = new ResponseCachingPolicy(true, false, false, true);
         request = new BasicHttpRequest("HEAD", "/foo?s=bar");
         response.setHeader("Date", DateUtils.formatStandardDate(now));
         response.setHeader("Expires", DateUtils.formatStandardDate(tenSecondsFromNow));
@@ -805,7 +674,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void getsWithQueryParametersFrom1_0OriginsViaProxiesCanNotBeCacheableEvenWithExpires() {
-        policy = new ResponseCachingPolicy(0, true, true, true, true);
+        policy = new ResponseCachingPolicy(true, true, true, true);
         request = new BasicHttpRequest("GET", "/foo?s=bar");
         response.setHeader("Date", DateUtils.formatStandardDate(now));
         response.setHeader("Expires", DateUtils.formatStandardDate(tenSecondsFromNow));
@@ -815,7 +684,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void headsWithQueryParametersFrom1_0OriginsViaProxiesCanNotBeCacheableEvenWithExpires() {
-        policy = new ResponseCachingPolicy(0, true, true, true, true);
+        policy = new ResponseCachingPolicy(true, true, true, true);
         request = new BasicHttpRequest("HEAD", "/foo?s=bar");
         response.setHeader("Date", DateUtils.formatStandardDate(now));
         response.setHeader("Expires", DateUtils.formatStandardDate(tenSecondsFromNow));
@@ -834,7 +703,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void headsWithQueryParametersFrom1_0OriginsViaExplicitProxiesAreCacheableWithExpires() {
-        policy = new ResponseCachingPolicy(0, true, false, false, false);
+        policy = new ResponseCachingPolicy(true, false, false, false);
         request = new BasicHttpRequest("HEAD", "/foo?s=bar");
         response.setHeader("Date", DateUtils.formatStandardDate(now));
         response.setHeader("Expires", DateUtils.formatStandardDate(tenSecondsFromNow));
@@ -844,7 +713,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void getsWithQueryParametersFrom1_0OriginsViaExplicitProxiesCanNotBeCacheableEvenWithExpires() {
-        policy = new ResponseCachingPolicy(0, true, true, true, true);
+        policy = new ResponseCachingPolicy(true, true, true, true);
         request = new BasicHttpRequest("GET", "/foo?s=bar");
         response.setHeader("Date", DateUtils.formatStandardDate(now));
         response.setHeader("Expires", DateUtils.formatStandardDate(tenSecondsFromNow));
@@ -854,7 +723,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void headsWithQueryParametersFrom1_0OriginsViaExplicitProxiesCanNotBeCacheableEvenWithExpires() {
-        policy = new ResponseCachingPolicy(0, true, true, true, true);
+        policy = new ResponseCachingPolicy(true, true, true, true);
         request = new BasicHttpRequest("HEAD", "/foo?s=bar");
         response.setHeader("Date", DateUtils.formatStandardDate(now));
         response.setHeader("Expires", DateUtils.formatStandardDate(tenSecondsFromNow));
@@ -875,7 +744,7 @@ public class TestResponseCachingPolicy {
 
     @Test
     public void headsWithQueryParametersFrom1_1OriginsVia1_0ProxiesAreCacheableWithExpires() {
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
+        policy = new ResponseCachingPolicy(true, false, false, true);
         request = new BasicHttpRequest("HEAD", "/foo?s=bar");
         response = new BasicHttpResponse(HttpStatus.SC_OK, "OK");
         response.setVersion(HttpVersion.HTTP_1_0);
@@ -914,7 +783,7 @@ public class TestResponseCachingPolicy {
     public void test303WithExplicitCachingHeadersWhenPermittedByConfig() {
         // HTTPbis working group says ok if explicitly indicated by
         // response headers
-        policy = new ResponseCachingPolicy(0, true, false, true, true);
+        policy = new ResponseCachingPolicy(true, false, true, true);
         response.setCode(HttpStatus.SC_SEE_OTHER);
         response.setHeader("Date", DateUtils.formatStandardDate(now));
         responseCacheControl = ResponseCacheControl.builder()
@@ -955,8 +824,8 @@ public class TestResponseCachingPolicy {
 
 
         // Create ResponseCachingPolicy instance and test the method
-        policy = new ResponseCachingPolicy(0, true, false, false, false);
-        request = new BasicHttpRequest("POST", "/foo");
+        policy = new ResponseCachingPolicy(true, false, false, false);
+        request = new BasicHttpRequest("GET", "/foo");
         assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
@@ -973,8 +842,8 @@ public class TestResponseCachingPolicy {
 
 
         // Create ResponseCachingPolicy instance and test the method
-        policy = new ResponseCachingPolicy(0, true, false, false, false);
-        request = new BasicHttpRequest("POST", "/foo");
+        policy = new ResponseCachingPolicy(true, false, false, false);
+        request = new BasicHttpRequest("GET", "/foo");
         responseCacheControl = ResponseCacheControl.builder()
                 .setMaxAge(60)
                 .build();
@@ -993,8 +862,8 @@ public class TestResponseCachingPolicy {
 
 
         // Create ResponseCachingPolicy instance and test the method
-        policy = new ResponseCachingPolicy(0, true, false, false,false);
-        request = new BasicHttpRequest("POST", "/foo");
+        policy = new ResponseCachingPolicy(true, false, false,false);
+        request = new BasicHttpRequest("GET", "/foo");
         responseCacheControl = ResponseCacheControl.builder()
                 .setMaxAge(60)
                 .build();
@@ -1013,8 +882,8 @@ public class TestResponseCachingPolicy {
 
 
         // Create ResponseCachingPolicy instance and test the method
-        policy = new ResponseCachingPolicy(0, true, false, false,false);
-        request = new BasicHttpRequest("POST", "/foo");
+        policy = new ResponseCachingPolicy(true, false, false,false);
+        request = new BasicHttpRequest("GET", "/foo");
         assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 
@@ -1029,7 +898,7 @@ public class TestResponseCachingPolicy {
         request = new BasicHttpRequest("GET","/foo?s=bar");
         // HTTPbis working group says ok if explicitly indicated by
         // response headers
-        policy = new ResponseCachingPolicy(0, true, false, true, true);
+        policy = new ResponseCachingPolicy(true, false, true, true);
         response.setCode(HttpStatus.SC_OK);
         response.setHeader("Date", DateUtils.formatStandardDate(now));
         assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
@@ -1042,7 +911,7 @@ public class TestResponseCachingPolicy {
         response.setHeader(HttpHeaders.DATE, DateUtils.formatStandardDate(Instant.now()));
 
         // Create ResponseCachingPolicy instance and test the method
-        policy = new ResponseCachingPolicy(0, true, false, false, true);
+        policy = new ResponseCachingPolicy(true, false, false, true);
         request = new BasicHttpRequest("GET", "/foo");
         responseCacheControl = ResponseCacheControl.builder()
                 .setNoCache(true)
@@ -1057,7 +926,7 @@ public class TestResponseCachingPolicy {
         response.setHeader(HttpHeaders.DATE, DateUtils.formatStandardDate(Instant.now()));
 
         // Create ResponseCachingPolicy instance and test the method
-        policy = new ResponseCachingPolicy(0, true, false, false, false);
+        policy = new ResponseCachingPolicy(true, false, false, false);
         request = new BasicHttpRequest("GET", "/foo");
         responseCacheControl = ResponseCacheControl.builder()
                 .setNoStore(true)
@@ -1072,6 +941,6 @@ public class TestResponseCachingPolicy {
                 .setMaxAge(3600) // set this to a value that ensures the response is still fresh
                 .build();
 
-        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, "GET", response));
+        Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }
 }
\ No newline at end of file