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
HTTP Caching #103
Comments
I'm also want to know about it |
No news on caching? |
you can use this fork |
@navabi don't you have a copy of this repo? it has been deleted. |
Anyway, this is going to wait for #75 for platform provided caching. |
@smarek that repo was not fully implemented and the owner has deleted it. examples of using aq can be found here: |
This will be provided by using OkHttp instead of DefaultHttpClient, using HttpUrlConnection has it's perks, such as HttpResponseCache. |
印象笔记无法提交笔记,原因如下: 本月帐户上传流量已经达到上限。 原消息详情: 为了防止邮件过多,接下来的360分钟内,你将不会收到报错回复。 升级到印象笔记高级帐户,可以发送的邮件数量将从50封提升到200封。
|
any updates on this issue? |
Since OkHttp integration is not considered anymore, in 1.5.0 branch will be possible to implement caching eg. via https://hc.apache.org/httpcomponents-client-ga/httpclient-cache/apidocs/org/apache/http/impl/client/cache/CachingHttpClientBuilder.html |
I have fix it.https://github.com/79144876/android-async-http-loopj-with-cache |
@79144876 nice work, but you haven't fixed it, because we are talking about http protocol cache, not about caching specific data (thus all work with ormlite, json/gson, etc... is wrong, in the same way as it is wrong to store whole large json objects within database). still might inspire someone, but it's not implementation or workaround for http caching feature. |
oh , i got it. maybe you can use CachingHttpClient for it. but i have not test it. |
@79144876 that is indeed correct suggestion, however, as of now, library depends on system provided version of DefaultHttpClient, which is ofc wrong, and will be dealt with. |
Yeah.your library depends on system provided version of DefaultHttpClient.if you want to update it to CachingHttpClient, it's not easy work (may be you can do this on other branch.we will stand by.) |
My implements version: https://github.com/panxw/android-async-http-cached |
Well, to give you update, currently with 1.4.9 we adopted upstream AFS HttpClient v4.3.3, with HttpClient-Cache bundled within. So upstream provided Caching workflows should be now available, see the upstream documentation: https://hc.apache.org/httpcomponents-client-ga/tutorial/html/caching.html |
@smarek can you please provide more information about how this works with |
To be a bit more specific, I'm confused how this exposed through this library. Based on the linked documents, it would appear that I would need a way to override the |
Well, to explain. Also the library Which means, only thing you have to do is follow upstream instructions on how to use HttpClient-Cache https://hc.apache.org/httpcomponents-client-ga/tutorial/html/caching.html to configure the library. In version 1.5.0 (which is currently in development) I'll provide library API to configure caching, with version < 1.5.0 you have to do this manually. |
Hi @smarek, sorry for the delayed response, I'm just returning from family leave. Any chance you might have a snapshot of |
Hi @FreakTheMighty, in fact we've migrated over to using upstream HttpClient 4.3.X with android-async-http branch 1.4.9, so if you want to test caching, it's possible with latest production version of library. 1.5.0 will only rewrite implementation of interfaces and will use more upstream code for implementing its functions. |
@smarek I see that 1.4.9 has the new client, but the apache tutorial appears to indicate that configuration needs to happen as part of a chain of factory methods. That is, it doesn't looks like the configuration of a client can be updated after its been initialized. If the client configuration cannot be updated after being initialized, then I'd like to set android-async-http with a configured client. This doesn't seem possible because there is only a getter for the http client. My currently plan is to modify the android-async-http source and rebuild. I would be happy (and not surprised) if I'm missing something. |
Sadly you're not missing anything, there is no setter for HttpClient so far, however you can get to override used HttpClient via subclassing AsyncHttpClient class and overriding There is HttpClient configuration class coming up with next release, so unless that will be available, this is nice way to implement desired function. Simple subclass example can be found here: https://github.com/loopj/android-async-http/blob/master/sample/src/main/java/com/loopj/android/http/sample/SampleParentActivity.java#L76 |
@smarek thanks for taking the time to look into this. The new builder is giving me a bunch of trouble. My subclass of public class CachedAsyncHttpClient extends AsyncHttpClient {
@Override
protected AsyncHttpRequest newAsyncHttpRequest(DefaultHttpClient client, HttpContext httpContext,
HttpUriRequest uriRequest, String contentType,
ResponseHandlerInterface responseHandler,
Context context) {
CacheConfig cacheConfig = CacheConfig.custom()
.setMaxCacheEntries(1000)
.setMaxObjectSize(8192)
.build();
CloseableHttpClient cachingClient = CachingHttpClients.custom()
.setCacheConfig(cacheConfig)
.build();
return new AsyncHttpRequest(cachingClient, httpContext, uriRequest, responseHandler);
}
} What I'm finding, however, is that it's not possible to build or cast to a subclass of |
Use the variable not with |
I think the issue lies in |
The |
@FreakTheMighty have you solved the problem? I'm facing the same issue |
@smarek the case closed, Can I contribute to resolve it ? |
Does anybody know if it's possible to enable HTTP caching?
If there was this library would be perfect :)
The text was updated successfully, but these errors were encountered: