[
https://issues.apache.org/jira/browse/HTTPCLIENT-1487?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13940315#comment-13940315
]
Oleg Kalnichevski commented on HTTPCLIENT-1487:
-----------------------------------------------
@Chris
In default configuration caching HttpClient deletes cache entries in disk when
shut down. I personally do not think this is unreasonable.
{code:java}
CacheConfig config = CacheConfig.DEFAULT;
CloseableHttpClient client = CachingHttpClients.custom()
.setCacheConfig(config)
.setCacheDir(new File("my-cache"))
.build();
{code}
One can override the default behavior by managing cache storage manually.
{code:java}
CacheConfig config = CacheConfig.DEFAULT;
FileResourceFactory resourceFactory = new FileResourceFactory(new
File("my-cache"));
ManagedHttpCacheStorage cacheStorage = new ManagedHttpCacheStorage(config);
CloseableHttpClient client = CachingHttpClients.custom()
.setCacheConfig(config)
.setResourceFactory(resourceFactory)
.setHttpCacheStorage(cacheStorage)
.build();
// This will not affect cache storage
client.close();
// use #cleanResources instead of #close to preserve valid cache entries
cacheStorage.cleanResources();
//cacheStorage.close();
{code}
Oleg
> CachingHttpClient doesn't persist cache
> ---------------------------------------
>
> Key: HTTPCLIENT-1487
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1487
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Reporter: Chris Oliver
> Assignee: Jon Moore
> Priority: Blocker
>
> Unless I'm mistaken, the current implementation doesn't maintain the cache
> between executions of the java process. In addition, it appears the current
> api for HttpCacheStorage makes it difficult / error prone to do this myself,
> since my implementation would have to somehow produce an HttpCacheEntry. Any
> suggestions?
--
This message was sent by Atlassian JIRA
(v6.2#6252)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]