Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

CacheConfig option for HttpClient #445

Closed
RokLenarcic opened this issue Apr 14, 2018 · 3 comments
Closed

CacheConfig option for HttpClient #445

RokLenarcic opened this issue Apr 14, 2018 · 3 comments
Assignees

Comments

@RokLenarcic
Copy link
Contributor

Currently the client doesn't support setting CacheConfig, which would enable the client to honor the caching headers are per RFC. All that is really needed is a change to build-http-client to read :cache-config request option for a possible CacheConfig object.

Example use from HttpComponents:

CacheConfig cacheConfig = CacheConfig.custom()
        .setMaxCacheEntries(1000)
        .setMaxObjectSize(8192)
        .build();
RequestConfig requestConfig = RequestConfig.custom()
        .setConnectTimeout(30000)
        .setSocketTimeout(30000)
        .build();
CloseableHttpClient cachingClient = CachingHttpClients.custom()
        .setCacheConfig(cacheConfig)
        .setDefaultRequestConfig(requestConfig)
        .build();

@dakrone
Copy link
Owner

dakrone commented Apr 18, 2018

Sounds good, I'll add this

@dakrone
Copy link
Owner

dakrone commented Apr 19, 2018

@RokLenarcic I've pushed a commit that adds this! can you take a look (at the commit or master branch) and let me know what you think?

dakrone added a commit that referenced this issue Apr 19, 2018
This adds the option to configure Apache's httpclient-cache library in a
request. When multiple requests reuse a client and connection manager, the
response can be cached and returned for a much faster response for multiple
retrievals of the same URL.

This caching is transparent to the requestor, and a user can see whether the
response was returned from a cache using the `:cached` key in the response.

Caching is turned off by default and can be turned on by setting `:cache` to
`true`. Cache options can be configured through a `:cache-config` map in the
request option map. See `core/build-cache-config` for all available options.

Resolves #445
@RokLenarcic
Copy link
Contributor Author

Looks great!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants