Skip to content

Commit

Permalink
fix(image): [android] removing noStore from builder when force cache …
Browse files Browse the repository at this point in the history
…or only-if-cached
  • Loading branch information
mateoguzmana committed Nov 8, 2024
1 parent dbf007e commit dca3d3a
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ internal class ReactOkHttpNetworkFetcher(private val okHttpClient: OkHttpClient)
fetchState.submitTime = SystemClock.elapsedRealtime()
val uri = fetchState.uri
var requestHeaders: Map<String, String>? = null
val cacheControlBuilder = CacheControl.Builder().noStore()
val cacheControlBuilder = CacheControl.Builder()
if (fetchState.context.imageRequest is ReactNetworkImageRequest) {
val networkImageRequest = fetchState.context.imageRequest as ReactNetworkImageRequest
requestHeaders = getHeaders(networkImageRequest.headers)
when (networkImageRequest.cacheControl) {
ImageCacheControl.RELOAD -> {
cacheControlBuilder.noCache()
cacheControlBuilder.noStore().noCache()
}
ImageCacheControl.FORCE_CACHE -> {
cacheControlBuilder
.onlyIfCached()
.maxStale(Integer.MAX_VALUE, TimeUnit.SECONDS)
cacheControlBuilder.maxStale(Integer.MAX_VALUE, TimeUnit.SECONDS)
}
ImageCacheControl.ONLY_IF_CACHED -> {
cacheControlBuilder.onlyIfCached()
cacheControlBuilder.onlyIfCached().maxStale(Integer.MAX_VALUE, TimeUnit.SECONDS)
}
ImageCacheControl.DEFAULT -> {
// No-op
cacheControlBuilder.noStore()
}
}
} else {
cacheControlBuilder.noStore()
}
val headers = OkHttpCompat.getHeadersFromMap(requestHeaders)
val request =
Expand Down

0 comments on commit dca3d3a

Please sign in to comment.