Android 改装:连接超时时从缓存读取

Android 改装:连接超时时从缓存读取,android,http,caching,retrofit,okhttp,Android,Http,Caching,Retrofit,Okhttp,如果发生连接超时,是否有方法从缓存中读取 所有缓存都在工作,但它只在没有internet的情况下工作 我已经知道如何检查超时异常: @Override public void onFailure(Call call, Throwable t) { if(t instanceof SocketTimeoutException){ // I want to load from cache here. } }

如果发生连接超时,是否有方法从缓存中读取

所有缓存都在工作,但它只在没有internet的情况下工作

我已经知道如何检查超时异常:

@Override
public void onFailure(Call call, Throwable t) {
    if(t instanceof SocketTimeoutException){
        // I want to load from cache here.
    }
}