We are moving away from HttpClient to now use RestTemplate, even better FeignClient. But looking at the https://github.com/OpenFeign/feign it seems Response Caching is in road map of feign 11.
I was looking at possibility of writing a custom mechanism to support Caching based on Cache Control headers. I will try to explain this with sample example
Service A exposes an API /greet/{name}. This API sends max-age response header so that client can cache the response.
Service B calls this API using FeignClient
Below is sample Feign Interface.
@FeignClient(name="app/app", contextId="AppService", configuration=AppConfig.class)
public interface AppFeignService {
@GET
@Path(value = "/api/greet/{name}")
public String greet(@PathParam("name") String name);
}
One way to support caching is, add an intermediate layer above feign client and cache the response based on needs. But this takes the caching logic to client side and I want to make sure the decision of how much to cache (max-age header) should be left to server and client shouldn't drive it.
Question here is - do we know when we can expect caching support in Feign? Is there any interim solution we can go with to still have caching support? Feign is really good considering its abstraction and we do not really want to write code to call it using RestTemplate.
Your recommendations are highly appreciated.