Running the code below, it looks like the cache freshness is not updated even through successful fetches, until the Kotlin/JS code exposed by the server is actually updated.
To reproduce:
Run the launchZipline function below multiple times with a valid network
Observe the log freshAtEpochMs that is triggered in the FreshnessChecker.isFresh callback
The freshAtEpochMs is always the same, even after multiple successful fetches -> ISSUE
Update the Kotlin/JS code on the server
Re-trigger the launchZipline function
The freshAtEpochMs is updated
suspend fun launchZipline(dispatcher: CoroutineDispatcher): Zipline? {
val manifestUrl = "http://10.0.2.2:8080/manifest.zipline.json"
val ziplineCache = ZiplineCache(
applicationContext,
FileSystem.SYSTEM,
applicationContext.cacheDir.toOkioPath(),
10 * 1024 * 1024, // 10MB
)
val loader = ZiplineLoader(
dispatcher,
ManifestVerifier.NO_SIGNATURE_CHECKS,
OkHttpClient(),
).withCache(ziplineCache)
val cacheDuration = Duration.ofMinutes(1L)
val freshnessChecker = object : FreshnessChecker {
override fun isFresh(manifest: ZiplineManifest, freshAtEpochMs: Long): Boolean =
(System.currentTimeMillis() - freshAtEpochMs < cacheDuration.toMillis())
.also {
Log.d("Zipline", "freshAtEpochMs: $freshAtEpochMs")
Log.d("Zipline", "Is the cache fresh? $it")
}
}
return when (
val result = loader.loadOnce(AppZiplineInterfaceName, freshnessChecker, manifestUrl)
) {
is LoadResult.Success -> {
Log.d("Zipline", "Zipline loaded freshAtEpochMs: ${result.freshAtEpochMs}")
result.zipline
}
is LoadResult.Failure -> {
Log.e("Zipline", "Failed to load Zipline \n ${result.exception.message}")
null
}
}
}
On Zipline v1.10.1
Running the code below, it looks like the cache freshness is not updated even through successful fetches, until the Kotlin/JS code exposed by the server is actually updated.
To reproduce:
freshAtEpochMs
that is triggered in theFreshnessChecker.isFresh
callbackfreshAtEpochMs
is always the same, even after multiple successful fetches -> ISSUElaunchZipline
functionfreshAtEpochMs
is updated