示例代码:
final CacheConfig cacheConfig = CacheConfig.custom()
.setMaxCacheEntries(50)
.setMaxObjectSize(800)
.setHeuristicCachingEnabled(true)
.setHeuristicDefaultLifetime(5)
.build();
final CloseableHttpClient httpClient = CachingHttpClients.custom()
.setCacheConfig(cacheConfig)
.build();
final HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
final RestTemplate restTemplate = new RestTemplate(factory);
restClient.getForObject("serverUri"); //this is never hitting the cache.
看起来像apacheHttpClient从未调用过?