···77} from "@opennextjs/aws/types/overrides.js";
8899import { getCloudflareContext } from "../../cloudflare-context.js";
1010-import { debugCache, FALLBACK_BUILD_ID, IncrementalCacheEntry } from "../internal.js";
1010+import { debugCache, FALLBACK_BUILD_ID, IncrementalCacheEntry, isPurgeCacheEnabled } from "../internal.js";
1111import { NAME as KV_CACHE_NAME } from "./kv-incremental-cache.js";
12121313const ONE_MINUTE_IN_SECONDS = 60;
···8282 throw new Error("The KV incremental cache does not need a regional cache.");
8383 }
8484 this.name = this.store.name;
8585- this.opts.shouldLazilyUpdateOnCacheHit ??=
8686- this.opts.mode === "long-lived" && !this.#hasAutomaticCachePurging;
8585+ this.opts.shouldLazilyUpdateOnCacheHit ??= this.opts.mode === "long-lived" && !isPurgeCacheEnabled();
8786 }
88878988 get #bypassTagCacheOnCacheHit(): boolean {
···9392 }
94939594 // Otherwise we default to whether the automatic cache purging is enabled or not
9696- return this.#hasAutomaticCachePurging;
9797- }
9898-9999- get #hasAutomaticCachePurging() {
100100- // The `?` is required at `openNextConfig?` or the Open Next build fails because of a type error
101101- const cdnInvalidation = globalThis.openNextConfig?.default?.override?.cdnInvalidation;
102102-103103- return cdnInvalidation !== undefined && cdnInvalidation !== "dummy";
9595+ return isPurgeCacheEnabled();
10496 }
1059710698 async get<CacheType extends CacheEntryType = "cache">(
+7
packages/cloudflare/src/api/overrides/internal.ts
···3232 return `${prefix}/${buildId}/${hash}.${cacheType}`.replace(/\/+/g, "/");
3333}
34343535+export function isPurgeCacheEnabled(): boolean {
3636+ // The `?` is required at `openNextConfig?` or the Open Next build fails because of a type error
3737+ const cdnInvalidation = globalThis.openNextConfig?.default?.override?.cdnInvalidation;
3838+3939+ return cdnInvalidation !== undefined && cdnInvalidation !== "dummy";
4040+}
4141+3542export async function purgeCacheByTags(tags: string[]) {
3643 const { env } = getCloudflareContext();
3744 // We have a durable object for purging cache