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

Jon Moore commented on HTTPCLIENT-1515:
---------------------------------------

Sorry I haven't been able to look at this in detail (long story).

First: I do think the 5.0 release probably ought to revisit the current cache 
system design. There are enough issues with it that I think we can rethink it 
successfully.

Second: I am not crazy about changing the binary signature on HttpCacheEntry or 
with making it serialization-incompatible. Some cache implementations may well 
persist entities for a long period of time and may have a large cache already; 
we should not lightly invalidate everyone's existing caches.

However, I think there is an easy solution here:
1. When caching HEAD or GET requests, add a new (extension) header that stores 
the request method. For example, 'Hc-Request-Method: GET'. This allows us to 
use the existing serialization schemes and is backwards-compatible, and retains 
existing cache keys.
2. I agree with Francois-Xavier that we do not need two cache entries for the 
same variant; if we have done both a HEAD and a GET then the latter is a 
sufficient cache entry for both.
3. When attempting to serve a GET request, we may use the cache entry (per 
existing cache logic) as long as it either has no Hc-Request-Method header or 
has one with 'Hc-Request-Method: GET'. Any other values of that header, should 
be translated into a full GET request to the origin and proceed as normal.
4. A cache entry can be used to serve a HEAD request (per existing HTTP caching 
rules) if this header is missing or has value 'GET' or 'HEAD'.

How does that all sound?


> Caching responses to HEAD requests
> ----------------------------------
>
>                 Key: HTTPCLIENT-1515
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1515
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: HttpCache
>            Reporter: Tyrone Cutajar
>             Fix For: 4.4 Final
>
>
> Our system retrieves metadata via HEAD requests using HTTP Client 4.x and 
> would benefit immensely from having the headers in the response cached.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to