Created
October 28, 2020 06:53
-
-
Save Ikhiloya/15f504fa016851dc51e07178da755e27 to your computer and use it in GitHub Desktop.
check if this request has the Cacheable annotation
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
if (annotation != null && | |
annotation.annotationClass.simpleName.equals("Cacheable") && | |
!PaymentApp.instance!!.isNetworkConnected()) { | |
// prevent caching when network is on. For that we use the "networkInterceptor" | |
Timber.d("cache interceptor: called.") | |
val cacheControl = CacheControl.Builder() | |
.maxStale(7, TimeUnit.DAYS) | |
.build() | |
request = request.newBuilder() | |
.removeHeader(HEADER_PRAGMA) | |
.removeHeader(HEADER_CACHE_CONTROL) | |
.cacheControl(cacheControl) | |
.build() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment