UNPKG

@aziontech/opennextjs-azion

Version:
19 lines (18 loc) 817 B
/** * This code was originally copied and modified from the @opennextjs/cloudflare repository. * Significant changes have been made to adapt it for use with Azion. */ import { createHash } from "node:crypto"; export const debugCache = (name, ...args) => { if (process.env.NEXT_PRIVATE_DEBUG_CACHE) { console.log(`[${name}] `, ...args); } }; export const FALLBACK_BUILD_ID = "no-build-id"; export const DEFAULT_PREFIX = "incremental-cache"; export const NAME_FILE_TAG_MANIFEST = "cache-tags-manifest.cache"; export function computeCacheKey(key, options) { const { cacheType = "cache", prefix = DEFAULT_PREFIX, buildId = FALLBACK_BUILD_ID } = options; const hash = createHash("sha256").update(key).digest("hex"); return `${prefix}/${buildId}/${hash}.${cacheType}`.replace(/\/+/g, "/"); }