Skip to content

Commit 56e5c3c

Browse files
authored
Parse cache tags returned from the API set them in response (#2349)
1 parent 1dc3234 commit 56e5c3c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib/cache/http.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ export function parseCacheResponse(response: Response): {
2626
const cacheControlHeader = response.headers.get('cache-control');
2727
const cacheControl = cacheControlHeader ? parseCacheControl(cacheControlHeader) : null;
2828

29+
const cacheTagHeader = response.headers.get('x-gitbook-cache-tag');
30+
const tags = !cacheTagHeader ? [] : cacheTagHeader.split(',');
31+
2932
const entry = {
3033
ttl: 60 * 60 * 24,
31-
tags: [],
34+
tags,
3235
};
3336

3437
if (cacheControl && cacheControl['max-age']) {

0 commit comments

Comments
 (0)