title: Can Retrofit with OKHttp use cache data when offline
body: <p>I'm trying to use Retrofit &amp; OKHttp to cache HTTP responses. I followed <a href="https://gist.github.com/swankjesse/5889518" rel="noreferrer" title="gist">this gist</a> and, ended up with this code:</p>
  
  <pre class="lang-java prettyprint-override"><code>File httpCacheDirectory = new File(context.getCacheDir(), "responses");
  
  HttpResponseCache httpResponseCache = null;
  try {
       httpResponseCache = new HttpResponseCache(httpCacheDirectory, 10 * 1024 * 1024);
  } catch (IOException e) {
       Log.e("Retrofit", "Could not create http cache", e);
  }
  
  OkHttpClient okHttpClient = new OkHttpClient();
  okHttpClient.setResponseCache(httpResponseCache);
  
  api = new RestAdapter.Builder()
            .setEndpoint(API_URL)
            .setLogLevel(RestAdapter.LogLevel.FULL)
            .setClient(new OkClient(okHttpClient))
            .build()
            .create(MyApi.class);
  </code></pre>
  
  <p>And this is MyApi with the Cache-Control headers
  </p>
  
  <pre><code>public interface MyApi {
     @Headers("Cache-Control: public, max-age=640000, s-maxage=640000 , max-stale=2419200")
     @GET("/api/v1/person/1/")
     void requestPerson(
             Callback&lt;Person&gt; callback
     );
  </code></pre>
  
  <p>First I request online and check the cache files. The correct JSON response and headers are there. But when I try to request offline, I always get <code>RetrofitError UnknownHostException</code>. Is there anything else I should do to make Retrofit read the response from cache?</p>
  
  <p><strong>EDIT:</strong>
  Since OKHttp 2.0.x <code>HttpResponseCache</code> is <code>Cache</code>, <code>setResponseCache</code> is <code>setCache</code></p>