Skip to content

Commit 339d5c0

Browse files
committed
Support cacheControl value in set context
1 parent e81e248 commit 339d5c0

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

packages/cache-handler/src/cache-handler.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,10 @@ export class CacheHandler implements NextCacheHandler {
865865
incrementalCacheValue: CacheHandlerParametersSet[1],
866866
ctx: CacheHandlerParametersSet[2] & { neshca_lastModified?: number },
867867
): Promise<void> {
868-
if (incrementalCacheValue?.kind !== CachedRouteKind.PAGES) {
868+
if (
869+
incrementalCacheValue?.kind !== CachedRouteKind.PAGES ||
870+
ctx.fetchCache === true
871+
) {
869872
return;
870873
}
871874

@@ -880,7 +883,9 @@ export class CacheHandler implements NextCacheHandler {
880883
);
881884
}
882885

883-
const { revalidate, neshca_lastModified } = ctx;
886+
const { neshca_lastModified, cacheControl } = ctx;
887+
888+
const revalidate = cacheControl?.revalidate;
884889

885890
const lastModified = Math.round(neshca_lastModified ?? Date.now());
886891

packages/cache-handler/src/instrumentation/register-initial-cache.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ export async function registerInitialCache(
180180
headers: undefined,
181181
status: undefined,
182182
},
183-
{ revalidate, neshca_lastModified: lastModified },
183+
{
184+
neshca_lastModified: lastModified,
185+
fetchCache: false,
186+
cacheControl: { revalidate, expire: 0 },
187+
},
184188
);
185189
} catch (error) {
186190
if (debug) {

0 commit comments

Comments
 (0)