Skip to content

Commit 6ee3121

Browse files
committed
don't check tag cache for page router
1 parent 6324a23 commit 6ee3121

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

packages/open-next/src/adapters/cache.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default class Cache {
6666
const _hasBeenRevalidated = await hasBeenRevalidated(
6767
key,
6868
_tags,
69-
cachedEntry?.lastModified,
69+
cachedEntry,
7070
);
7171

7272
if (_hasBeenRevalidated) return null;
@@ -85,7 +85,7 @@ export default class Cache {
8585
const hasPathBeenUpdated = await hasBeenRevalidated(
8686
path.replace("_N_T_/", ""),
8787
[],
88-
cachedEntry.lastModified,
88+
cachedEntry,
8989
);
9090
if (hasPathBeenUpdated) {
9191
// In case the path has been revalidated, we don't want to use the fetch cache
@@ -121,7 +121,7 @@ export default class Cache {
121121
const _hasBeenRevalidated = await hasBeenRevalidated(
122122
key,
123123
tags,
124-
_lastModified,
124+
cachedEntry,
125125
);
126126
if (cacheData === undefined || _hasBeenRevalidated) return null;
127127

packages/open-next/src/core/routing/cacheInterceptor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export async function cacheInterceptor(
168168
const _hasBeenRevalidated = await hasBeenRevalidated(
169169
localizedPath,
170170
tags,
171-
cachedData.lastModified,
171+
cachedData,
172172
);
173173
if (_hasBeenRevalidated) {
174174
return event;

packages/open-next/src/types/cache.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export type TagCacheMetaFile = {
9797
path: { S: string };
9898
revalidatedAt: { N: string };
9999
};
100+
100101
export type IncrementalCacheContext = {
101102
revalidate?: number | false | undefined;
102103
fetchCache?: boolean | undefined;

packages/open-next/src/utils/cache.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
import type { CacheValue } from "types/overrides";
1+
import type { CacheValue, WithLastModified } from "types/overrides";
22

33
export async function hasBeenRevalidated(
44
key: string,
55
tags: string[],
6-
lastModified?: number,
6+
cacheEntry: WithLastModified<CacheValue<any>>,
77
): Promise<boolean> {
88
if (globalThis.openNextConfig.dangerous?.disableTagCache) {
99
return false;
1010
}
11+
const value = cacheEntry.value;
12+
if (!value) {
13+
// We should never reach this point
14+
return true;
15+
}
16+
if ("type" in cacheEntry && cacheEntry.type === "page") {
17+
return false;
18+
}
19+
const lastModified = cacheEntry.lastModified ?? Date.now();
1120
if (globalThis.tagCache.mode === "nextMode") {
1221
return await globalThis.tagCache.hasBeenRevalidated(tags, lastModified);
1322
}

0 commit comments

Comments
 (0)