Disable Cache of okhttp
add interceptor to your client, and add cache control header in interceptor.check sample code below:
Interceptor interceptor = new Interceptor() {
@Override public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
Request.Builder builder = request.newBuilder().addHeader("Cache-Control", "no-cache");
request = builder.build();
return chain.proceed(request);
}
};
OkHttpClient mClient = new OkHttpClient.Builder()
.addInterceptor(interceptor)
.build();
Use this to build Retrofit and provide cache as null
the API will not cache anything.
private OkHttpClient createOkHttpClient() {
return new OkHttpClient.Builder()
...
.cache(null)
.build();
}