From 03b59038f8e75a487bdf407c82a6c9847a4b7ced Mon Sep 17 00:00:00 2001 From: Johan Preynat Date: Wed, 19 Jun 2024 17:29:52 +0200 Subject: [PATCH] Parse cache tags returned from the API set them in response --- src/lib/cache/http.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/cache/http.ts b/src/lib/cache/http.ts index 1cfc67ed2..145ae78de 100644 --- a/src/lib/cache/http.ts +++ b/src/lib/cache/http.ts @@ -26,9 +26,12 @@ export function parseCacheResponse(response: Response): { const cacheControlHeader = response.headers.get('cache-control'); const cacheControl = cacheControlHeader ? parseCacheControl(cacheControlHeader) : null; + const cacheTagHeader = response.headers.get('x-gitbook-cache-tag'); + const tags = !cacheTagHeader ? [] : cacheTagHeader.split(','); + const entry = { ttl: 60 * 60 * 24, - tags: [], + tags, }; if (cacheControl && cacheControl['max-age']) {