Skip to content

Commit

Permalink
Merge pull request #21 from vivid-planet/smaxage
Browse files Browse the repository at this point in the history
Support s-maxage cache-control value
  • Loading branch information
dkarnutsch authored Oct 10, 2023
2 parents 50acccf + a694727 commit 79dfe18
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ export function parseMeta(res: Response): CacheMeta | null {
if (!cacheControl) {
return null;
}
const maxAgeMatch = cacheControl.match(/max-age=(\d+)/);
const maxAgeMatch = cacheControl.match(/(max-age|s-maxage)=(\d+)/);
if (!maxAgeMatch) {
return null;
}

const status = res.status;
const headers = convertHeadersToObject(res.headers);

const maxAge = parseInt(maxAgeMatch[1], 10) * 1000;
const maxAge = parseInt(maxAgeMatch[2], 10) * 1000;
const staleWhileRevalidateMatch = cacheControl.match(/stale-while-revalidate=(\d+)/);
if (!staleWhileRevalidateMatch) {
return { maxAge, headers, status };
Expand Down

0 comments on commit 79dfe18

Please sign in to comment.