Skip to content

Commit 7867811

Browse files
committed
Added max age of cached responses with at most 15 mins unless manual sync
1 parent 6968216 commit 7867811

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

app/src/main/java/com/nononsenseapps/feeder/model/FeedParser.kt

+13-11
Original file line numberDiff line numberDiff line change
@@ -350,18 +350,20 @@ suspend fun OkHttpClient.getResponse(
350350
): Response {
351351
val request = Request.Builder()
352352
.url(url)
353-
.run {
354-
if (forceNetwork) {
355-
cacheControl(
356-
CacheControl.Builder()
357-
// Force cache-revalidation
358-
.maxAge(0, TimeUnit.SECONDS)
359-
.build(),
353+
.cacheControl(
354+
CacheControl.Builder()
355+
// The time between cache re-validations
356+
.maxAge(
357+
if (forceNetwork) {
358+
0
359+
} else {
360+
// Matches fastest sync schedule
361+
15
362+
},
363+
TimeUnit.MINUTES,
360364
)
361-
} else {
362-
this
363-
}
364-
}
365+
.build(),
366+
)
365367
.build()
366368

367369
@Suppress("BlockingMethodInNonBlockingContext")

0 commit comments

Comments
 (0)