You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "arturobernalg (via GitHub)" <gi...@apache.org> on 2026/08/11 18:50:32 UTC

[PR] RFC 9211: optional Cache-Status response header [httpcomponents-client]

arturobernalg opened a new pull request, #867:
URL: https://github.com/apache/httpcomponents-client/pull/867

   Adds optional support for the RFC 9211 Cache-Status response header to the caching executors.
   
   When enabled, the cache records how each response was produced — a cache hit,cor a forward to the origin with the reason (bypass, method, uri-miss, vary-miss, request, stale) and the upstream status code where relevant — and emits a
   Cache-Status header identified as Apache-HttpClient.
   
   Disabled by default; enabled with `CacheConfig.setCacheStatusEnabled(true)`.
   Applies to both the classic and async cache execution paths.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] RFC 9211: optional Cache-Status response header [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on code in PR #867:
URL: https://github.com/apache/httpcomponents-client/pull/867#discussion_r3797816185


##########
httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheContext.java:
##########
@@ -122,6 +124,7 @@ public static HttpCacheContext create() {
     private RequestCacheControl requestCacheControl;
     private ResponseCacheControl responseCacheControl;
     private HttpCacheEntry cacheEntry;
+    private CacheStatus cacheStatus;

Review Comment:
   @arturobernalg `CacheResponseStatus` and `CacheStatus` now overlap. Is there any chance we could get rid of `responseStatus` attribute and generate its value from `cacheStatus` on the fly?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] RFC 9211: optional Cache-Status response header [httpcomponents-client]

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on code in PR #867:
URL: https://github.com/apache/httpcomponents-client/pull/867#discussion_r3792430743


##########
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java:
##########
@@ -131,6 +130,41 @@ SimpleHttpResponse generateGatewayTimeout() {
         return SimpleHttpResponse.create(HttpStatus.SC_GATEWAY_TIMEOUT, "Gateway Timeout");
     }
 
+    /**
+     * Internal context attribute holding the per-exchange {@link CacheStatus} used to render the
+     * RFC 9211 {@code Cache-Status} header.
+     */
+    static final String CACHE_STATUS_ATTR = "http.cache.status";

Review Comment:
   @ok2c  Good point — done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] RFC 9211: optional Cache-Status response header [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on code in PR #867:
URL: https://github.com/apache/httpcomponents-client/pull/867#discussion_r3791823496


##########
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java:
##########
@@ -131,6 +130,41 @@ SimpleHttpResponse generateGatewayTimeout() {
         return SimpleHttpResponse.create(HttpStatus.SC_GATEWAY_TIMEOUT, "Gateway Timeout");
     }
 
+    /**
+     * Internal context attribute holding the per-exchange {@link CacheStatus} used to render the
+     * RFC 9211 {@code Cache-Status} header.
+     */
+    static final String CACHE_STATUS_ATTR = "http.cache.status";

Review Comment:
   @arturobernalg Why? Why not making it a proper context attribute like `CacheResponseStatus`, `RequestCacheControl`, `ResponseCacheControl`, etc? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] RFC 9211: optional Cache-Status response header [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on code in PR #867:
URL: https://github.com/apache/httpcomponents-client/pull/867#discussion_r3805533063


##########
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java:
##########
@@ -293,6 +300,15 @@ public void doExecute(
             if (LOG.isDebugEnabled()) {
                 LOG.debug("{} request cannot be served from cache", exchangeId);
             }
+            // The cache lookup is bypassed here (non-cacheable method, or a no-store / no-cache
+            // request), so no stored response was ever selected; this is not fwd=request.
+            final String method = cacheRequest.getMethod();
+            final boolean cacheSupportedMethod = Method.GET.isSame(method)

Review Comment:
   @arturobernalg Please make  `CacheableRequestPolicy` and `ResponseCachingPolicy` use this method as well



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] RFC 9211: optional Cache-Status response header [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on code in PR #867:
URL: https://github.com/apache/httpcomponents-client/pull/867#discussion_r3805116162


##########
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java:
##########
@@ -293,6 +300,15 @@ public void doExecute(
             if (LOG.isDebugEnabled()) {
                 LOG.debug("{} request cannot be served from cache", exchangeId);
             }
+            // The cache lookup is bypassed here (non-cacheable method, or a no-store / no-cache
+            // request), so no stored response was ever selected; this is not fwd=request.
+            final String method = cacheRequest.getMethod();
+            final boolean cacheSupportedMethod = Method.GET.isSame(method)

Review Comment:
   @arturobernalg Let's move this bit into `CacheSupport`. Looks good otherwise.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] RFC 9211: optional Cache-Status response header [httpcomponents-client]

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg merged PR #867:
URL: https://github.com/apache/httpcomponents-client/pull/867


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org