Skip to content
New issue

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

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

Already on GitHub? Sign in 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
Labels

Comments

@RokLenarcic
Copy link
Contributor

@RokLenarcic RokLenarcic commented Apr 14, 2018

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

This comment has been minimized.

Copy link
Owner

@dakrone dakrone commented Apr 18, 2018

Sounds good, I'll add this

@dakrone dakrone self-assigned this Apr 18, 2018
@dakrone dakrone closed this in 2843e45 Apr 19, 2018
@dakrone

This comment has been minimized.

Copy link
Owner

@dakrone 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

This comment has been minimized.

Copy link
Contributor Author

@RokLenarcic RokLenarcic commented Apr 19, 2018

Looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.