diff --git a/src/build/content/prerendered.ts b/src/build/content/prerendered.ts index 9f1ae2fe75..b93e5e11fa 100644 --- a/src/build/content/prerendered.ts +++ b/src/build/content/prerendered.ts @@ -46,7 +46,7 @@ const writeCacheEntry = async ( const routeToFilePath = (path: string) => (path === '/' ? '/index' : path) const buildPagesCacheValue = async (path: string): Promise => ({ - kind: 'PAGE', + kind: 'PAGES', html: await readFile(`${path}.html`, 'utf-8'), pageData: JSON.parse(await readFile(`${path}.json`, 'utf-8')), headers: undefined, @@ -97,7 +97,7 @@ const buildRouteCacheValue = async ( path: string, initialRevalidateSeconds: number | false, ): Promise => ({ - kind: 'ROUTE', + kind: 'APP_ROUTE', body: await readFile(`${path}.body`, 'base64'), ...JSON.parse(await readFile(`${path}.meta`, 'utf-8')), revalidate: initialRevalidateSeconds, @@ -171,7 +171,7 @@ export const copyPrerenderedContent = async (ctx: PluginContext): Promise } // Netlify Forms are not support and require a workaround - if (value.kind === 'PAGE' || value.kind === 'APP_PAGE') { + if (value.kind === 'PAGE' || value.kind === 'PAGES' || value.kind === 'APP_PAGE') { verifyNetlifyForms(ctx, value.html) } diff --git a/src/run/handlers/cache.cts b/src/run/handlers/cache.cts index 790c89004e..e8c94c6758 100644 --- a/src/run/handlers/cache.cts +++ b/src/run/handlers/cache.cts @@ -132,13 +132,18 @@ export class NetlifyCacheHandler implements CacheHandler { if ( cacheValue.kind === 'PAGE' || + cacheValue.kind === 'PAGES' || cacheValue.kind === 'APP_PAGE' || - cacheValue.kind === 'ROUTE' + cacheValue.kind === 'ROUTE' || + cacheValue.kind === 'APP_ROUTE' ) { if (cacheValue.headers?.[NEXT_CACHE_TAGS_HEADER]) { const cacheTags = (cacheValue.headers[NEXT_CACHE_TAGS_HEADER] as string).split(',') requestContext.responseCacheTags = cacheTags - } else if (cacheValue.kind === 'PAGE' && typeof cacheValue.pageData === 'object') { + } else if ( + (cacheValue.kind === 'PAGE' || cacheValue.kind === 'PAGES') && + typeof cacheValue.pageData === 'object' + ) { // pages router doesn't have cache tags headers in PAGE cache value // so we need to generate appropriate cache tags for it const cacheTags = [`_N_T_${key === '/index' ? '/' : key}`] @@ -186,6 +191,7 @@ export class NetlifyCacheHandler implements CacheHandler { } async get(...args: Parameters): ReturnType { + debugger return this.tracer.withActiveSpan('get cache key', async (span) => { const [key, ctx = {}] = args getLogger().debug(`[NetlifyCacheHandler.get]: ${key}`) @@ -224,8 +230,9 @@ export class NetlifyCacheHandler implements CacheHandler { value: blob.value, } - case 'ROUTE': { - span.addEvent('ROUTE', { lastModified: blob.lastModified, status: blob.value.status }) + case 'ROUTE': + case 'APP_ROUTE': { + span.addEvent('APP_ROUTE', { lastModified: blob.lastModified, status: blob.value.status }) const valueWithoutRevalidate = this.captureRouteRevalidateAndRemoveFromObject(blob.value) @@ -237,7 +244,8 @@ export class NetlifyCacheHandler implements CacheHandler { }, } } - case 'PAGE': { + case 'PAGE': + case 'PAGES': { span.addEvent('PAGE', { lastModified: blob.lastModified }) const { revalidate, ...restOfPageValue } = blob.value @@ -275,7 +283,7 @@ export class NetlifyCacheHandler implements CacheHandler { data: Parameters[1], context: Parameters[2], ): NetlifyIncrementalCacheValue | null { - if (data?.kind === 'ROUTE') { + if (data?.kind === 'ROUTE' || data?.kind === 'APP_ROUTE') { return { ...data, revalidate: context.revalidate, @@ -283,7 +291,7 @@ export class NetlifyCacheHandler implements CacheHandler { } } - if (data?.kind === 'PAGE') { + if (data?.kind === 'PAGE' || data?.kind === 'PAGES') { return { ...data, revalidate: context.revalidate, @@ -397,8 +405,10 @@ export class NetlifyCacheHandler implements CacheHandler { cacheTags = [...tags, ...softTags] } else if ( cacheEntry.value?.kind === 'PAGE' || + cacheEntry.value?.kind === 'PAGES' || cacheEntry.value?.kind === 'APP_PAGE' || - cacheEntry.value?.kind === 'ROUTE' + cacheEntry.value?.kind === 'ROUTE' || + cacheEntry.value?.kind === 'APP_ROUTE' ) { cacheTags = (cacheEntry.value.headers?.[NEXT_CACHE_TAGS_HEADER] as string)?.split(',') || [] } else { diff --git a/src/shared/cache-types.cts b/src/shared/cache-types.cts index 06cee07516..f638a14aa1 100644 --- a/src/shared/cache-types.cts +++ b/src/shared/cache-types.cts @@ -28,7 +28,7 @@ export type NetlifyCachedAppPageValue = Omit[2]['revalidate'] } -type CachedPageValue = Extract +type CachedPageValue = Extract export type NetlifyCachedPageValue = CachedPageValue & { revalidate?: Parameters[2]['revalidate']