You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Vianney Carel (JIRA)" <ji...@apache.org> on 2010/08/20 15:00:23 UTC

[jira] Created: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Issue Comment Edited: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

Posted by "Jonathan Moore (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12900714#action_12900714 ] 

Jonathan Moore edited comment on HTTPCLIENT-982 at 8/24/10 9:33 AM:
--------------------------------------------------------------------

The CachedHttpResponseGenerator sets an Age header and a Via header. Is that sufficient, or would you like to see something more explicit? For example, we could add an extension header:

X-HttpClient-Cache: HIT
X-HttpClient-Cache: HIT, VALIDATED
X-HttpClient-Cache: HIT, REFRESHED
X-HttpClient-Cache: MISS
X-HttpClient-Cache: UNCACHEABLE

etc. 

Squid does something similar to this.

      was (Author: cimjmoore):
    The CachedHttpResponseGenerator sets an Age header and a Via header. Is that sufficient, or would you like to see something more explicitorRor example, we could add an extension header:

X-HttpClient-Cache: HIT
X-HttpClient-Cache: HIT, VALIDATED
X-HttpClient-Cache: HIT, REFRESHED
X-HttpClient-Cache: MISS
X-HttpClient-Cache: UNCACHEABLE

etc. 

Squid does something similar to this.
  
> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Updated: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

Posted by "Jonathan Moore (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-982?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Moore updated HTTPCLIENT-982:
--------------------------------------

    Attachment: cache-context.patch

I've attached a patch to set an attribute on an incoming HttpContext detailing how a request got handled by CachingHttpClient.

I selected a key of "http.cache.response.context" (this is a public constant on CachingHttpClient), although I'm not familiar with the usual conventions for this. The attribute values are members of the CacheResponseContext enum.

This patch is contributed with the permission of my employer.


> 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
>         Attachments: cache-context.patch
>
>
> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

Posted by "Jonathan Moore (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12902463#action_12902463 ] 

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

Ok, I am working on a patch for this, and would like to solicit some opinions. Current enum has:

CACHE_MODULE_RESPONSE : if the response was generated directly by the caching module itself (neither pulled from the cache nor taken from an upstream response)
CACHE_HIT : response generated from cache with no upstream request
CACHE_MISS : response came from upstream request
VALIDATED : response generated from cache after upstream validation

In the case where a cache entry is stale, and validation fails due to an IOException, the CachingHttpClient currently either:
(a) generates a 502 (Gateway Timeout) for must-revalidate and proxy-revalidate responses. I'm guessing this should be CACHE_MODULE_RESPONSE.
(b) generates a stale cache entry and attaches a Warning header. Should this be CACHE_HIT?

Or do we need new enum values to cover these cases?


> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Resolved: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-982?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCLIENT-982.
------------------------------------------

    Fix Version/s: 4.1 Alpha3
       Resolution: Fixed

Patch checked in. I made one change, though. I renamed CacheResponseContext to CacheResponseStatus, as the term 'context' bears a different connotation in the HttpClient API. I hope this is okay with. If not, let us think of a better term / enum name.

Oleg

> 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
>             Fix For: 4.1 Alpha3
>
>         Attachments: cache-context.patch
>
>
> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

Posted by "Vianney Carel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901920#action_12901920 ] 

Vianney Carel commented on HTTPCLIENT-982:
------------------------------------------

I only need from my end to generate a log containing the time, URL, user-agent, etc. of the request, plus the response code of the server and a flag telling if it was served from the local cache or not. That log will be used to monitor the I/O of the application using the HttpClient.

I don't mind much if the caching client adds specific headers for caching. Nevertheless, from a general perspective, I would expect it to not change anything in the response except the headers mentioned in the HTTP RFC. I believe the idea of caching a response including all its headers on one hand, and return the cached response with some headers modified on the other hand is somehow disturbing. So the less the client would do that, the happier I would be.

But... the client does cache the responses headers, doesn't it  ? (I confess I didn't check that point...)

> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

Posted by "Vianney Carel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901821#action_12901821 ] 

Vianney Carel commented on HTTPCLIENT-982:
------------------------------------------

I didn't integrate the latest snapshot (i'm still on alpha-2), so I cannot see the Age & Via headers. I'm afraid anyway that it's not enough to know if the response has been cached or not [by the client]. Because those headers could come from the back-end server without beeing overwritten by the client, if it doesn't cache the response. Right ?

About adding other headers to the response, I wouldn't recommand it. Actually, there wouldn't be the RFC, I wouldn't recommand adding headers at all, because one of the basics thing I expect from a cache is to keep data unchanged. Besides, it would be very confusing if a server would produce the same headers that the caching client uses.

Therefore I believe that cache-related information would better be in the request's HttpContext rather than in the response's headers.
What do you think ?

NB: having the same kind of headers as Squid produces would be perfect for my use... but not in the response ;-)

> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Issue Comment Edited: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

Posted by "Vianney Carel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901920#action_12901920 ] 

Vianney Carel edited comment on HTTPCLIENT-982 at 8/24/10 11:22 AM:
--------------------------------------------------------------------

I only need from my end to generate a log containing the time, URL, user-agent, etc. of the request, plus the response code of the server and a flag telling if it was served from the local cache or not. That log will be used to monitor the I/O of the application using the HttpClient.

I don't mind much if the caching client adds specific headers for caching. Nevertheless, from a general perspective, I would expect it to not change anything in the response except the headers mentioned in the HTTP RFC. I believe the idea of caching a response including all its headers on one hand, and returning the cached response with some headers modified on the other hand is somehow disturbing. So the less the client would do that, the happier I would be.

But... the client does cache the responses headers, doesn't it  ? (I confess I didn't check that point...)

      was (Author: vcarel):
    I only need from my end to generate a log containing the time, URL, user-agent, etc. of the request, plus the response code of the server and a flag telling if it was served from the local cache or not. That log will be used to monitor the I/O of the application using the HttpClient.

I don't mind much if the caching client adds specific headers for caching. Nevertheless, from a general perspective, I would expect it to not change anything in the response except the headers mentioned in the HTTP RFC. I believe the idea of caching a response including all its headers on one hand, and return the cached response with some headers modified on the other hand is somehow disturbing. So the less the client would do that, the happier I would be.

But... the client does cache the responses headers, doesn't it  ? (I confess I didn't check that point...)
  
> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

Posted by "Jonathan Moore (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901934#action_12901934 ] 

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

Hi Vianney,

Yes, the cache retains the response headers it receives, and doesn't *modify* any of them except as required by the RFC (e.g. Age, Via, Warning). Any extension headers it added would be strictly additions (and thus retain the semantic meaning of the origin response).

Now that I understand more of what you're asking, perhaps we could just do the following (and Oleg, perhaps you could chime in on the usual way this is done).

Define an enum which is something like CachedResponseContext with values of:

* CACHE_HIT : response was generated from cache with no backend I/O
* CACHE_MISS: no appropriate cache entry was found
* VALIDATED: response was generated from cache after validation with origin

We could then pick a key for the HttpContext and store the result there (not sure what the proper naming convention would be here).

Jon

> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

Posted by "Jonathan Moore (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12903626#action_12903626 ] 

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

I'm fine with the "Status" naming--I wasn't really happy with the "Context" naming either. Thanks!

> 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
>             Fix For: 4.1 Alpha3
>
>         Attachments: cache-context.patch
>
>
> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

Posted by "Jonathan Moore (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12900714#action_12900714 ] 

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

The CachedHttpResponseGenerator sets an Age header and a Via header. Is that sufficient, or would you like to see something more explicitorRor example, we could add an extension header:

X-HttpClient-Cache: HIT
X-HttpClient-Cache: HIT, VALIDATED
X-HttpClient-Cache: HIT, REFRESHED
X-HttpClient-Cache: MISS
X-HttpClient-Cache: UNCACHEABLE

etc. 

Squid does something similar to this.

> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

Posted by "Vianney Carel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901964#action_12901964 ] 

Vianney Carel commented on HTTPCLIENT-982:
------------------------------------------

Hi Jon,
That would be very fine for me. :-)

> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12902415#action_12902415 ] 

Oleg Kalnichevski commented on HTTPCLIENT-982:
----------------------------------------------

A context attribute settable by CachingHttpClient sounds reasonable. Alternatively we could use a special subclass of BasicHttpResponse for responses generated from cached content, something along the line:

CachedHttpResponse extends BasicHttpResponse {
  
  // additional attributes
  Date requestDate;
  Date responseDate
  boolean validated;
  <what not>

}

Oleg

> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCLIENT-982) Could we get a way to know if the response has been served from the cache or not ?

Posted by "Jonathan Moore (JIRA)" <ji...@apache.org>.
    [ 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org