hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Moore <j...@apache.org>
Subject Re: default to cached response on error?
Date Fri, 07 Jun 2013 14:07:15 GMT
On Thu, Jun 6, 2013 at 10:24 PM, Sam Perman <sam@permans.com> wrote:

> I'm using the CachingHttpClient and have configured a retry handler for
> certain types of errors... but what I really want to do is use a
> cached response (for certain types of errors) and only retry if there is
> previously cached response.
> Is this possible?

Hi Sam,

The CachingHttpClient does implement RFC 5861[1], in particular the
cache control directive that Francois-Xavier mentioned may help you here if
you're able to have your origin set that or can include it in your
request[2]. The CachingHttpClient will already serve you an existing stale
cache entry if an IOException happens while waiting for an origin response.

Other than that, though, if you are talking about getting an explicit 4XX/5XX
error response from the server and using a stale cache entry instead, that
would not be RFC2616-compliant cache behavior and would have to be
implemented as an opt-in override option. Patches welcome!


[1] http://tools.ietf.org/html/rfc5861
[2] I just perused the source code again, and I think there's a bug (I'll
open a JIRA issue for it) where the stale-if-error request directive will
only work for revalidatable cache entries (that have ETag or
Last-Modified), although this should also be applicable to
non-revalidatable entries too.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message