Skip to content

Commit

Permalink
Parse cache tags returned from the API set them in response
Browse files Browse the repository at this point in the history
  • Loading branch information
jpreynat committed Jun 19, 2024
1 parent 1dc3234 commit 03b5903
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/cache/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down

0 comments on commit 03b5903

Please sign in to comment.