mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-04 20:43:11 +00:00
Mitigate long loading times on spaces with many files. (#260)
This commit is contained in:
@@ -482,6 +482,9 @@ const getRevisionAllFiles = cache(
|
||||
|
||||
return cacheResponse(response, { ...immutableCacheTtl_7days, data: files });
|
||||
},
|
||||
{
|
||||
timeout: 60 * 1000,
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+7
-3
@@ -63,8 +63,14 @@ export function cache<Args extends any[], Result>(
|
||||
|
||||
/** Default ttl (in seconds) */
|
||||
defaultTtl?: number;
|
||||
|
||||
/** When a request to the underlying resource will timeout. */
|
||||
timeout?: number;
|
||||
} = {},
|
||||
): CacheFunction<Args, Result> {
|
||||
// We stop everything after 10s to avoid pending requests
|
||||
const timeout = options.timeout ?? 1000 * 10;
|
||||
|
||||
const revalidate = singletonMap(
|
||||
async (key: string, signal: AbortSignal | undefined, ...args: Args) => {
|
||||
return await trace(
|
||||
@@ -131,9 +137,7 @@ export function cache<Args extends any[], Result>(
|
||||
},
|
||||
{
|
||||
signal,
|
||||
|
||||
// We stop everything after 10s to avoid pending requests
|
||||
timeout: 10 * 1000,
|
||||
timeout,
|
||||
|
||||
// We give 70ms to the caches to respond, otherwise we start fallbacking to the actual fetch
|
||||
// It should represents a bit more than the 90th percentile of the KV cache response time
|
||||
|
||||
Reference in New Issue
Block a user