I am using Apache cachingHttpClient to query a REST API from java code.
I want to cache some http response despite receiving "Cache-Control: no-cache" header which cause the cachingHttpClient to not cache the file.
With standalone http proxy such as squid,mod_cache..., I could tweak the configuration to ignore those headers and overide default behaviour.
I'd rather not go for standalone http proxy but rather go for 100% java code.
The request is being rejected by the CachedResponseSuitabilityChecker in the canCachedResponseBeUsed method. If you need different behavior, that's the class to implement your own version of, and then use the long constructor for cachingHttpClient
CachingHttpClient(HttpClient backend,
CacheValidityPolicy validityPolicy,
ResponseCachingPolicy responseCachingPolicy,
HttpCache responseCache,
CachedHttpResponseGenerator responseGenerator,
CacheableRequestPolicy cacheableRequestPolicy,
CachedResponseSuitabilityChecker suitabilityChecker,
ConditionalRequestBuilder conditionalRequestBuilder,
ResponseProtocolCompliance responseCompliance,
RequestProtocolCompliance requestCompliance)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With