OkHttp不会缓存视频,但是可以缓存其他文件

时间:2019-01-15 06:48:57

标签: java okhttp3

我在我的VideoPlayer中使用OkHttp来缓存视频和预加载视频。但不幸的是,我发现OkHttp不会缓存视频。我已经在OkHttpClient中设置了缓存和NetWorkInterceptor。谁能帮我吗?

public class VideoCacheInterceptor imlements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException{
        Response originResponse = chain.proceed(chain.request());
        return originResponse.newBuilder()
              .removeHeader("Pragma")
              .removeHeader("No-Cache")
              .removeHeader("Cache-Control")
              .header(Cache-Control", "public, max-age=" + INVPlayer.maxAge)
              .build();
    }

}

0 个答案:

没有答案