File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
packages/cloudflare/src/api/overrides/incremental-cache Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,17 @@ class RegionalCache implements IncrementalCache {
7272 }
7373 this . name = this . store . name ;
7474 this . opts . shouldLazilyUpdateOnCacheHit ??= this . opts . mode === "long-lived" ;
75- this . opts . bypassTagCacheOnCacheHit ??= getCloudflareContext ( ) . env . NEXT_CACHE_DO_PURGE ? true : false ;
75+ }
76+
77+ get #bypassTagCacheOnCacheHit( ) : boolean {
78+ if ( this . opts . bypassTagCacheOnCacheHit ) {
79+ // If the bypassTagCacheOnCacheHit option is set we return that one
80+ return this . opts . bypassTagCacheOnCacheHit ;
81+ }
82+
83+ // Otherwise we default to wether the automatic cache purging is enabled or not
84+ const hasAutomaticCachePurging = ! ! getCloudflareContext ( ) . env . NEXT_CACHE_DO_PURGE ;
85+ return hasAutomaticCachePurging ;
7686 }
7787
7888 async get < CacheType extends CacheEntryType = "cache" > (
@@ -113,7 +123,7 @@ class RegionalCache implements IncrementalCache {
113123 this . putToCache ( { key, cacheType, entry : { value, lastModified } } )
114124 ) ;
115125
116- return { value, lastModified, shouldBypassTagCache : this . opts . bypassTagCacheOnCacheHit } ;
126+ return { value, lastModified, shouldBypassTagCache : this . # bypassTagCacheOnCacheHit } ;
117127 } catch ( e ) {
118128 error ( "Failed to get from regional cache" , e ) ;
119129 return null ;
You can’t perform that action at this time.
0 commit comments