On Thu, Jun 6, 2013 at 10:24 PM, Sam Perman <[email protected]> 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 previously > cached response (for certain types of errors) and only retry if there is no > previously cached response. > > Is this possible? > Hi Sam, The CachingHttpClient does implement RFC 5861[1], in particular the stale-if-error 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! Jon [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.
