You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "David Waite (JIRA)" <ji...@apache.org> on 2011/05/13 22:55:47 UTC

[jira] [Created] (HTTPCLIENT-1090) CachingHttpClient should be able to cache ResponseHandler responses (or the result of some new form of ResponseHandler)

CachingHttpClient should be able to cache ResponseHandler responses (or the result of some new form of ResponseHandler)
-----------------------------------------------------------------------------------------------------------------------

                 Key: HTTPCLIENT-1090
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1090
             Project: HttpComponents HttpClient
          Issue Type: Improvement
          Components: HttpClient
    Affects Versions: 4.1.1
         Environment: Mac OS X 10.6.7 + Eclipse Helios SR2
            Reporter: David Waite
            Priority: Minor


When creating a ResponseHandler to parse the response value into a usable java object, I notice that the code is executed every time, even if the response object is served from cache. It would be nice to have a system where a ResponseHandler can be written such that its value is also served from cache. This may require a different interface which:
- Exposes just the values which are not altered when served from a cache
- Returns objects which can be cached out of process ( through documentation, and having the return type extend Serializable)

Alternatively, if there is a header uniquely identifying a response, a WeakHashMap could be used to provide a cache associating a response with a created object (although such a cache would not correlate to the HTTP cache in terms of retention)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (HTTPCLIENT-1090) CachingHttpClient should be able to cache ResponseHandler responses (or the result of some new form of ResponseHandler)

Posted by "Aaron Gaudio (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1090?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13205333#comment-13205333 ] 

Aaron Gaudio commented on HTTPCLIENT-1090:
------------------------------------------

I am just looking at upgrading to the latest HttpClient version and was wondering about this very issue.

For the most part, this could be implemented inside the ResponseHandler implementation itself (or, more generically, a ResponseHandler Decorator), by looking to see if the response was a cache miss or not, via CachingHttpClient.CACHE_RESPONSE_STATUS. This would let you react to cache misses or hits. It would also give you the flexibility for managing your object cache separate from your http response caches, but linking the two.

The only thing that would be missing would be the ability to invalidate an entry from your own cache in response to the http resource being invalidated. Could this be accomplished via a custom/decorating HttpCacheStorage?
                
> CachingHttpClient should be able to cache ResponseHandler responses (or the result of some new form of ResponseHandler)
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1090
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1090
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: HttpClient
>    Affects Versions: 4.1.1
>         Environment: Mac OS X 10.6.7 + Eclipse Helios SR2
>            Reporter: David Waite
>            Priority: Minor
>             Fix For: Future
>
>
> When creating a ResponseHandler to parse the response value into a usable java object, I notice that the code is executed every time, even if the response object is served from cache. It would be nice to have a system where a ResponseHandler can be written such that its value is also served from cache. This may require a different interface which:
> - Exposes just the values which are not altered when served from a cache
> - Returns objects which can be cached out of process ( through documentation, and having the return type extend Serializable)
> Alternatively, if there is a header uniquely identifying a response, a WeakHashMap could be used to provide a cache associating a response with a created object (although such a cache would not correlate to the HTTP cache in terms of retention)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Commented] (HTTPCLIENT-1090) CachingHttpClient should be able to cache ResponseHandler responses (or the result of some new form of ResponseHandler)

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

Jon Moore commented on HTTPCLIENT-1090:
---------------------------------------

@Mak: I think I'm suggesting something else that sits on top of CachingHttpClient but that reuses some of the HTTP caching logic that already exists in that module (ResponseCachingPolicy et al.).

                
> CachingHttpClient should be able to cache ResponseHandler responses (or the result of some new form of ResponseHandler)
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1090
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1090
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: HttpClient
>    Affects Versions: 4.1.1
>         Environment: Mac OS X 10.6.7 + Eclipse Helios SR2
>            Reporter: David Waite
>            Priority: Minor
>             Fix For: Future
>
>
> When creating a ResponseHandler to parse the response value into a usable java object, I notice that the code is executed every time, even if the response object is served from cache. It would be nice to have a system where a ResponseHandler can be written such that its value is also served from cache. This may require a different interface which:
> - Exposes just the values which are not altered when served from a cache
> - Returns objects which can be cached out of process ( through documentation, and having the return type extend Serializable)
> Alternatively, if there is a header uniquely identifying a response, a WeakHashMap could be used to provide a cache associating a response with a created object (although such a cache would not correlate to the HTTP cache in terms of retention)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Commented] (HTTPCLIENT-1090) CachingHttpClient should be able to cache ResponseHandler responses (or the result of some new form of ResponseHandler)

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

Jon Moore commented on HTTPCLIENT-1090:
---------------------------------------

Actually, I'm inclined, but I think Oleg has a point about having time to do it. :)

That said, this is something I've been thinking about, and I think the rough approach David outlined is probably right. I think roughly this is a caching layer on top of the CachingHttpClient with a slightly different interface. I think the easiest approach is to have this layer cache parsed object bodies along with origin response headers, then apply some of the same logic from the guts of CachingHttpClient to determine whether the parsed object can be returned as-is, or if revalidation is required. There's a bit of trickiness here, because I think maintaining the semantic transparency of HTTP caching is important, and we'd want to make sure that cached objects could be invalidated by POSTs to the appropriate URL, for example.


> CachingHttpClient should be able to cache ResponseHandler responses (or the result of some new form of ResponseHandler)
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1090
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1090
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: HttpClient
>    Affects Versions: 4.1.1
>         Environment: Mac OS X 10.6.7 + Eclipse Helios SR2
>            Reporter: David Waite
>            Priority: Minor
>             Fix For: Future
>
>
> When creating a ResponseHandler to parse the response value into a usable java object, I notice that the code is executed every time, even if the response object is served from cache. It would be nice to have a system where a ResponseHandler can be written such that its value is also served from cache. This may require a different interface which:
> - Exposes just the values which are not altered when served from a cache
> - Returns objects which can be cached out of process ( through documentation, and having the return type extend Serializable)
> Alternatively, if there is a header uniquely identifying a response, a WeakHashMap could be used to provide a cache associating a response with a created object (although such a cache would not correlate to the HTTP cache in terms of retention)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (HTTPCLIENT-1090) CachingHttpClient should be able to cache ResponseHandler responses (or the result of some new form of ResponseHandler)

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

Mak commented on HTTPCLIENT-1090:
---------------------------------

Jon, could you please elaborate? Are you suggesting changes to CachingHttpClient or extending from it to do this? 
                
> CachingHttpClient should be able to cache ResponseHandler responses (or the result of some new form of ResponseHandler)
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1090
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1090
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: HttpClient
>    Affects Versions: 4.1.1
>         Environment: Mac OS X 10.6.7 + Eclipse Helios SR2
>            Reporter: David Waite
>            Priority: Minor
>             Fix For: Future
>
>
> When creating a ResponseHandler to parse the response value into a usable java object, I notice that the code is executed every time, even if the response object is served from cache. It would be nice to have a system where a ResponseHandler can be written such that its value is also served from cache. This may require a different interface which:
> - Exposes just the values which are not altered when served from a cache
> - Returns objects which can be cached out of process ( through documentation, and having the return type extend Serializable)
> Alternatively, if there is a header uniquely identifying a response, a WeakHashMap could be used to provide a cache associating a response with a created object (although such a cache would not correlate to the HTTP cache in terms of retention)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Updated] (HTTPCLIENT-1090) CachingHttpClient should be able to cache ResponseHandler responses (or the result of some new form of ResponseHandler)

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

Oleg Kalnichevski updated HTTPCLIENT-1090:
------------------------------------------

    Fix Version/s: Future

David,
It is unlikely that any of the actual HttpClient committers would have time and inclination to develop such a feature in a foreseeable future, so the surest way to see it happen rather sooner than later is to contribute it yourself. 

We happily take patches ;-)

Oleg

> CachingHttpClient should be able to cache ResponseHandler responses (or the result of some new form of ResponseHandler)
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1090
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1090
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: HttpClient
>    Affects Versions: 4.1.1
>         Environment: Mac OS X 10.6.7 + Eclipse Helios SR2
>            Reporter: David Waite
>            Priority: Minor
>             Fix For: Future
>
>
> When creating a ResponseHandler to parse the response value into a usable java object, I notice that the code is executed every time, even if the response object is served from cache. It would be nice to have a system where a ResponseHandler can be written such that its value is also served from cache. This may require a different interface which:
> - Exposes just the values which are not altered when served from a cache
> - Returns objects which can be cached out of process ( through documentation, and having the return type extend Serializable)
> Alternatively, if there is a header uniquely identifying a response, a WeakHashMap could be used to provide a cache associating a response with a created object (although such a cache would not correlate to the HTTP cache in terms of retention)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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