[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901889#action_12901889
 ] 

Jonathan Moore commented on HTTPCLIENT-982:
-------------------------------------------

Can I ask what the use case is for specifically knowing whether a response was 
served from the (local) cache or not? The HTTP caching mechanism has been 
defined to maintain semantic transparency, with the notion that a client 
perhaps can tell whether a response case straight from an origin server or 
whether it was returned by a cache, and Age headers are the existing protocol 
mechanism for this:

"The presence of an Age header field in a response implies that a response is 
not first-hand."

http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.2.3

Note that there may be other (proxy) caches in between the client and the 
origin server that may be returning a cached response as well, not just the 
local cache.

The HTTP RFC has a very explicit definition of semantic transparency for a 
proxy, and we actually have unit tests that verify this behavior with the 
CachingHttpClient. Note that adding additional end-to-end headers (where 
extension headers are end-to-end headers) does not break semantic transparency, 
and, as above, various intermediate proxies may well have done that to the 
original response sent from the origin.

I'm really just bringing this up to make sure you're not expecting behavior 
from the local cache that may not be supported by compliant HTTP/1.1 caches in 
general.

Ok, all that being said, let's get down to use cases: why do you need to know 
if a *specific* response was returned by the cache or not? I think the answer 
to this can help us understand where the best place to deliver this would be.


> Could we get a way to know if the response has been served from the cache or 
> not ?
> ----------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-982
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-982
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: Cache
>    Affects Versions: 4.1 Alpha2
>            Reporter: Vianney Carel
>            Priority: Trivial
>
> Is there a way to know if the response has been served from the cache or not ?
> That's an information which might be useful for monitoring the activity of 
> the cache.
> If there's no current way, maybe a flag could be added in the request context 
> whenever the response comes from the cache ... ?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to