Is Retrofit+Okhttp using httpCaching as a default in Android?

android, http, http-caching, okhttp, retrofit

Solution

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

Also, no caching for HTTP POST requests. GETs will be cached, however.

Problem

I use retrofit and okhttp in one of our applications. I can't really find a good explanation for the default behaviour of Retrofit. 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. Do I need to explicitly enable caching with Retrofit and Okhttp?

Original source