PrefetchCache


@Profile.ExperimentalUrlPrefetch
class PrefetchCache


PrefetchCache manages the configuration of the prefetch cache for a Profile.

It allows applications to tune the behavior of prefetch cache by setting limits such as the maximum number of prefetches and the time-to-live for prefetched responses. These configurations are applied to all WebViews associated with the profile.

Use getPrefetchCache to obtain the PrefetchCache instance for a specific profile.

Summary

Public functions

Unit
@RequiresFeature(name = WebViewFeature.PREFETCH_CACHE_V1, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
@Profile.ExperimentalUrlPrefetch
setMaxPrefetches(maxPrefetches: @IntRange(from = 1) Int?)

Sets the maximum number of prefetches for the current browsing session.

Unit
@RequiresFeature(name = WebViewFeature.PREFETCH_CACHE_V1, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
@Profile.ExperimentalUrlPrefetch
setPrefetchTtlSeconds(prefetchTtlSeconds: @IntRange(from = 1) Int?)

Sets the maximum prefetch Time-to-Live (TTL) in seconds for the current browsing session.

Public functions

setMaxPrefetches

@RequiresFeature(name = WebViewFeature.PREFETCH_CACHE_V1, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
@Profile.ExperimentalUrlPrefetch
fun setMaxPrefetches(maxPrefetches: @IntRange(from = 1) Int?): Unit

Sets the maximum number of prefetches for the current browsing session.

These configurations will be applied to any prefetch requests made after they are set; they will not be applied to in-flight requests.

These configurations will be applied to WebViews that are associated with the Profile that owns this PrefetchCache.

Parameters
maxPrefetches: @IntRange(from = 1) Int?

the maximum number of prefetches to allow. Setting this value to null will use the default value.

setPrefetchTtlSeconds

@RequiresFeature(name = WebViewFeature.PREFETCH_CACHE_V1, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
@Profile.ExperimentalUrlPrefetch
fun setPrefetchTtlSeconds(prefetchTtlSeconds: @IntRange(from = 1) Int?): Unit

Sets the maximum prefetch Time-to-Live (TTL) in seconds for the current browsing session.

These configurations will be applied to any prefetch requests made after they are set; they will not be applied to in-flight requests.

These configurations will be applied to WebViews that are associated with the Profile that owns this PrefetchCache.

Parameters
prefetchTtlSeconds: @IntRange(from = 1) Int?

the TTL in seconds. Setting this value to null will use the default value.