[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpclient-users
Subject:    Re: Control behavior of Caching based on response
From:       Oleg Kalnichevski <olegk () apache ! org>
Date:       2020-02-28 18:17:47
Message-ID: 21580a8af18d146002eac14133dad9599d34fdcb.camel () apache ! org
[Download RAW message or body]

On Thu, 2020-02-27 at 14:01 -0800, Novice User wrote:
> Hi,
> 
> We're using HTTPClient 4.5.11 with caching enabled to make HTTP GET
> calls to our provider.
> 
> The provider returns JSON object and as JSON can miss some keys in
> some cases, we want to treat it as bad data and avoid it being
> cached.
> 
> There does not seem to be any hook for us to intercept the response
> body and inspect it and prevent it from being cached.
> 
> It seems HTTP Client has HttpCacheInvalidator but it would not work
> on GET requests, and also I would like something to avoid storing it
> in cache in first place if response is bad, rather than doing a post
> processing of invalidation.
> 
> Does HTTP client has any ability for us to intercept the response
> body before it could be saved in cache? 
> 
> Thanks,
> Akash

You could subclass CachingHttpClientBuilder, override #decorateMainExec
method and insert an extra interceptor between MainExec and
CachingExec.

Oleg 


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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic