@@ -35,14 +35,16 @@ type Options = {
35
35
* Whether the regional cache entry should be updated in the background or not when it experiences
36
36
* a cache hit.
37
37
*
38
- * @default `false` for the `short -lived` mode, and `true` for the `long-lived` mode .
38
+ * @default `true` in `long -lived` mode when cache purge is not used, `false` otherwise .
39
39
*/
40
40
shouldLazilyUpdateOnCacheHit ?: boolean ;
41
41
42
42
/**
43
43
* Whether on cache hits the tagCache should be skipped or not. Skipping the tagCache allows requests to be
44
- * handled faster, the downside of this is that you need to make sure that the cache gets correctly purged
45
- * either by enabling the auto cache purging feature or doing that manually.
44
+ * handled faster,
45
+ *
46
+ * Note: When this is enabled, make sure that the cache gets purged
47
+ * either by enabling the auto cache purging feature or manually.
46
48
*
47
49
* @default `true` if the auto cache purging is enabled, `false` otherwise.
48
50
*/
@@ -71,7 +73,8 @@ class RegionalCache implements IncrementalCache {
71
73
throw new Error ( "The KV incremental cache does not need a regional cache." ) ;
72
74
}
73
75
this . name = this . store . name ;
74
- this . opts . shouldLazilyUpdateOnCacheHit ??= this . opts . mode === "long-lived" ;
76
+ this . opts . shouldLazilyUpdateOnCacheHit ??=
77
+ this . opts . mode === "long-lived" && ! this . #hasAutomaticCachePurging;
75
78
}
76
79
77
80
get #bypassTagCacheOnCacheHit( ) : boolean {
@@ -103,7 +106,8 @@ class RegionalCache implements IncrementalCache {
103
106
if ( cachedResponse ) {
104
107
debugCache ( "Get - cached response" ) ;
105
108
106
- // Re-fetch from the store and update the regional cache in the background
109
+ // Re-fetch from the store and update the regional cache in the background.
110
+ // Note: this is only useful when the Cache API is not purged automatically.
107
111
if ( this . opts . shouldLazilyUpdateOnCacheHit ) {
108
112
getCloudflareContext ( ) . ctx . waitUntil (
109
113
this . store . get ( key , cacheType ) . then ( async ( rawEntry ) => {
0 commit comments