Skip to content

Commit 3a9efb8

Browse files
authored
bust revision page markdown (#4235)
1 parent f71ab84 commit 3a9efb8

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

packages/gitbook/openNext/customWorkers/defaultWrangler.jsonc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@
9292
},
9393
"staging": {
9494
"vars": {
95-
"OPEN_NEXT_REQUEST_ID_HEADER": "true",
96-
"NEXT_PRIVATE_DEBUG_CACHE": "true"
95+
"OPEN_NEXT_REQUEST_ID_HEADER": "true"
9796
},
9897
"r2_buckets": [
9998
{
@@ -137,8 +136,7 @@
137136
// This is a bit misleading, but it means that we can have 500 concurrent revalidations
138137
// This means that we'll have up to 100 durable objects instance running at the same time
139138
"MAX_REVALIDATE_CONCURRENCY": "100",
140-
"OPEN_NEXT_REQUEST_ID_HEADER": "true",
141-
"NEXT_PRIVATE_DEBUG_CACHE": "true"
139+
"OPEN_NEXT_REQUEST_ID_HEADER": "true"
142140
},
143141
"r2_buckets": [
144142
{

packages/gitbook/openNext/incrementalCache/incrementalCache.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export class GitbookIncrementalCache implements IncrementalCache {
2929
cacheType?: CacheType
3030
): Promise<WithLastModified<CacheValue<CacheType>> | null> {
3131
const cacheKey = this.getR2Key(key, cacheType);
32-
console.log(`[GitbookIncrementalCache] Getting cache for key: ${cacheKey}`, key, cacheType);
3332

3433
const r2 = getCloudflareContext().env[BINDING_NAME];
3534
if (!r2) throw new Error('No R2 bucket');

packages/gitbook/src/lib/data/api.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,18 @@ export function createDataFetcher(
8787
});
8888
},
8989
getRevisionPageMarkdown(params) {
90-
return getRevisionPageMarkdown(input, {
91-
spaceId: params.spaceId,
92-
revisionId: params.revisionId,
93-
pageId: params.pageId,
94-
});
90+
return getRevisionPageMarkdown(
91+
input,
92+
{
93+
spaceId: params.spaceId,
94+
revisionId: params.revisionId,
95+
pageId: params.pageId,
96+
},
97+
// We pass the name of the function to distinguish between cache entries
98+
// By default Next only uses the arguments, the filename and the position of the function inside the file
99+
// By adding a dummy argument with the function name, we can change the order without breaking anything
100+
'getRevisionPageMarkdown'
101+
);
95102
},
96103
getRevisionPageDocument(params) {
97104
return getRevisionPageDocument(
@@ -318,7 +325,9 @@ const getRevision = cache(
318325
const getRevisionPageMarkdown = cache(
319326
async (
320327
input: DataFetcherInput,
321-
params: { spaceId: string; revisionId: string; pageId: string }
328+
params: { spaceId: string; revisionId: string; pageId: string },
329+
// used only to bust the cache
330+
_functionName: string
322331
) => {
323332
'use cache: remote';
324333
return wrapCacheDataFetcherError(async () => {

0 commit comments

Comments
 (0)