Skip to content

Commit

Permalink
fix: bump cache from 7d to 31d (#1058)
Browse files Browse the repository at this point in the history
Increase the `cache-control` header from 7 days to 31 days
  • Loading branch information
styfle authored Aug 12, 2024
1 parent b774c66 commit 5985245
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export async function handler(req: IncomingMessage, res: ServerResponse) {
TMPDIR,
);
res.setHeader('Content-Type', mimeType('*.svg'));
res.setHeader('Cache-Control', cacheControl(isProd, cacheResult ? 7 : 0));
res.setHeader('Cache-Control', cacheControl(isProd, cacheResult ? 31 : 0));
res.end(getBadgeSvg(pkgSize));
} else if (pathname === pages.apiv1 || pathname === pages.apiv2) {
const parsed = parsePackageString(query.p as string);
Expand All @@ -94,7 +94,7 @@ export async function handler(req: IncomingMessage, res: ServerResponse) {
}
res.statusCode = version === versionUnknown ? 404 : 200;
res.setHeader('Content-Type', mimeType(pathname));
res.setHeader('Cache-Control', cacheControl(isProd, cacheResult ? 7 : 0));
res.setHeader('Cache-Control', cacheControl(isProd, cacheResult ? 31 : 0));
res.end(JSON.stringify(result));
} else if (pathname === pages.scanResults) {
let data: Buffer[] = [];
Expand All @@ -121,7 +121,7 @@ export async function handler(req: IncomingMessage, res: ServerResponse) {
const hasVersion =
typeof query.p === 'string' && parsePackageString(query.p).version !== null;
res.setHeader('Content-Type', mimeType('*.html'));
res.setHeader('Cache-Control', cacheControl(isProd, isIndex || hasVersion ? 7 : 0));
res.setHeader('Cache-Control', cacheControl(isProd, isIndex || hasVersion ? 31 : 0));
renderPage(res, pathname, query, TMPDIR, GA_ID);
}
} catch (e) {
Expand Down

0 comments on commit 5985245

Please sign in to comment.