【发布时间】:2016-08-03 07:51:59
【问题描述】:
我正在使用 Retrofit2 和 OKHttp 缓存 HTTP 响应。 这是我的代码:
int cacheSize = 10 * 1024 * 1024;
Cache cache = new Cache(application.getCacheDir(), cacheSize);
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder().
cache(cache).addNetworkInterceptor(interceptor).build();
Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.baseUrl(mBaseUrl)
.client(okHttpClient)
.build();
我正在从我们的后端 REST API 获取响应标头 Cache-control 和 Expires。
现在我想通过绕过 Expires 标头来获取服务器响应。 请帮我解决这个问题。
【问题讨论】:
标签: android http retrofit okhttp http-caching