Skip to content

Instantly share code, notes, and snippets.

@matdziu
Created October 27, 2016 13:47
Show Gist options
  • Select an option

  • Save matdziu/a15372bfbec7040569f3f2c62ca82cf9 to your computer and use it in GitHub Desktop.

Select an option

Save matdziu/a15372bfbec7040569f3f2c62ca82cf9 to your computer and use it in GitHub Desktop.
public class OnlineCacheInterceptor implements Interceptor {
@Override
public okhttp3.Response intercept(Chain chain) throws IOException {
okhttp3.Response response = chain.proceed(chain.request());
CacheControl cacheControl = new CacheControl.Builder()
.maxAge(30, TimeUnit.SECONDS)
.build();
return response.newBuilder()
.header("Cache-Control", cacheControl.toString())
.build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment