被改造+ Okhttp使用httpCaching作为Android的默认? [英] Is Retrofit+Okhttp using httpCaching as a default in Android?
问题描述
I use retrofit and okhttp in one of our applications.
我真的不能找到一个很好的解释了改造的默认行为。
I can't really find a good explanation for the default behaviour of Retrofit.
如果Okhttp是在类路径上它会自动使用。但据我可以看到它默认的Htt presponseCache为空。
If Okhttp is on the class path it will be automatically used. But as far as I can see it the default HttpResponseCache is null.
我是否需要明确启用缓存与改造和Okhttp?
Do I need to explicitly enable caching with Retrofit and Okhttp?
推荐答案
您应该手动创建OkHttpClient并配置它,你怎么样。在这种情况下,你应该安装一个高速缓存。一旦你有创建一个 OkClient ,并把它传递给改造的< A HREF =http://square.github.io/retrofit/javadoc/retrofit/RestAdapter.html相对=nofollow> RestAdapter.Builder
You should manually create your OkHttpClient and configure it how you like. In this case you should install a cache. Once you have that create an OkClient and pass it to Retrofit's RestAdapter.Builder
此外,没有缓存的HTTP POST请求。获取将被缓存,但是。
Also, no caching for HTTP POST requests. GETs will be cached, however.
这篇关于被改造+ Okhttp使用httpCaching作为Android的默认?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!