Skip to content

Commit 68287d3

Browse files
authored
Cache API spec for 24 hours, revalidated every 2 hours (#2792)
1 parent dff08ae commit 68287d3

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.changeset/five-students-rescue.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'gitbook': patch
3+
---
4+
5+
Cache API spec for 24 hours, revalidated every 2 hours

packages/gitbook/src/lib/openapi.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
OpenAPIParseError,
88
} from '@gitbook/react-openapi';
99

10-
import { cache, parseCacheResponse, noCacheFetchOptions, CacheFunctionOptions } from '@/lib/cache';
10+
import { cache, noCacheFetchOptions, CacheFunctionOptions } from '@/lib/cache';
1111

1212
import { parseMarkdown } from './markdown';
1313
import { ResolvedContentRef } from './references';
@@ -68,7 +68,10 @@ const fetcher: OpenAPIFetcher = {
6868
const text = await response.text();
6969
const data = await parseOpenAPI({ url, value: text, parseMarkdown });
7070
return {
71-
...parseCacheResponse(response),
71+
// Cache for 4 hours
72+
ttl: 24 * 60 * 60,
73+
// Revalidate every 2 hours
74+
revalidateBefore: 22 * 60 * 60,
7275
data,
7376
};
7477
},

0 commit comments

Comments
 (0)