Skip to content

Commit 991b2d5

Browse files
committed
Cache webfont files for 30 days
1 parent 624d73d commit 991b2d5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/request-handling.ts

+7
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,16 @@ export async function servePublic(req: http.ServerRequest, path: string) {
4545
.catch(makeErrorResponse)
4646
.then(resp => req.respond(resp));
4747
}
48+
4849
export async function serveFont(req: http.ServerRequest, path: string) {
4950
await file_server
5051
.serveFile(req, 'fonts/'+path)
52+
.then(resp => {
53+
if (resp.status === 200) {
54+
resp.headers?.set('cache-control', 'public, max-age=2592000'); // 30d
55+
}
56+
return resp;
57+
})
5158
.catch(makeErrorResponse)
5259
.then(resp => req.respond(resp));
5360
}

0 commit comments

Comments
 (0)