Cache API spec for 24 hours, revalidated every 2 hours (#2792)

This commit is contained in:
Greg Bergé
2025-01-30 15:16:45 +01:00
committed by GitHub
parent dff08ae3e3
commit 68287d3df4
2 changed files with 10 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'gitbook': patch
---
Cache API spec for 24 hours, revalidated every 2 hours
+5 -2
View File
@@ -7,7 +7,7 @@ import {
OpenAPIParseError,
} from '@gitbook/react-openapi';
import { cache, parseCacheResponse, noCacheFetchOptions, CacheFunctionOptions } from '@/lib/cache';
import { cache, noCacheFetchOptions, CacheFunctionOptions } from '@/lib/cache';
import { parseMarkdown } from './markdown';
import { ResolvedContentRef } from './references';
@@ -68,7 +68,10 @@ const fetcher: OpenAPIFetcher = {
const text = await response.text();
const data = await parseOpenAPI({ url, value: text, parseMarkdown });
return {
...parseCacheResponse(response),
// Cache for 4 hours
ttl: 24 * 60 * 60,
// Revalidate every 2 hours
revalidateBefore: 22 * 60 * 60,
data,
};
},