Skip to content

Commit

Permalink
Move respectCacheHeaders(false) out of CoilImageSource#resolve()
Browse files Browse the repository at this point in the history
  • Loading branch information
saket committed Jul 2, 2024
1 parent 923f0c3 commit 676b0da
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ internal class CoilImageSource(
?: ImageRequest.Builder(context)
.data(model)
.build(),
imageLoader = imageLoader
.newBuilder()
// Ignore "no-cache" http headers if they're present and always cache images to disk. Otherwise,
// telephoto will be unable to sub-sample large images directly from coil's memory cache.
.respectCacheHeaders(false)
.build(),
imageLoader = imageLoader,
sizeResolver = { canvasSize.first().toCoilSize() }
)
}
Expand Down Expand Up @@ -92,6 +87,13 @@ internal class Resolver(
}

private suspend fun work(skipMemoryCache: Boolean) {
val imageLoader = imageLoader
.newBuilder()
// Ignore "no-store" http headers if they're present and always cache images to disk. Otherwise,
// telephoto will be unable to sub-sample large images directly from coil's memory cache.
.respectCacheHeaders(false)
.build()

val result = imageLoader.execute(
request.newBuilder()
.size(request.defined.sizeResolver ?: sizeResolver)
Expand Down Expand Up @@ -190,7 +192,7 @@ internal class Resolver(
result.dataSource.let { it == DataSource.DISK || it == DataSource.MEMORY_CACHE } -> {
// Possible reasons for reaching this code path:
// - Locally stored images such as assets, resource, etc.
// - Remote image that wasn't saved to disk because of a "no-cache" HTTP header.
// - Remote image that wasn't saved to disk because of a "no-store" HTTP header.
result.request.mapRequestDataToUriOrNull()?.let { uri ->
SubSamplingImageSource.contentUriOrNull(uri, preview)
}
Expand Down

0 comments on commit 676b0da

Please sign in to comment.