Last active
May 28, 2020 14:46
-
-
Save shikto1/98977449f929f1d742e4bc9b98dd926d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static Interceptor onlineInterceptor = new Interceptor() { | |
| @Override | |
| public okhttp3.Response intercept(Chain chain) throws IOException { | |
| okhttp3.Response response = chain.proceed(chain.request()); | |
| int maxAge = 60; // read from cache for 60 seconds even if there is internet connection | |
| return response.newBuilder() | |
| .header("Cache-Control", "public, max-age=" + maxAge) | |
| .removeHeader("Pragma") | |
| .build(); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment