feat(frontend): Add Cache-Control header to frontends served

This commit is contained in:
Jesse Wierzbinski 2024-04-21 22:37:34 -10:00
parent 9834825184
commit 5dd6ea4d10
No known key found for this signature in database
2 changed files with 4 additions and 0 deletions

View file

@ -94,6 +94,7 @@ const handleManifestRequest = async () => {
headers: { headers: {
"Content-Type": "application/json; charset=utf-8", "Content-Type": "application/json; charset=utf-8",
"Content-Length": String(JSON.stringify(manifest).length), "Content-Length": String(JSON.stringify(manifest).length),
"Cache-Control": "max-age=31536000",
Date: new Date().toUTCString(), Date: new Date().toUTCString(),
}, },
}); });
@ -171,6 +172,7 @@ const returnFile = async (file: BunFile, content?: string) => {
headers: { headers: {
"Content-Type": `${file.type}; charset=utf-8`, "Content-Type": `${file.type}; charset=utf-8`,
"Content-Length": String(file.size), "Content-Length": String(file.size),
"Cache-Control": "max-age=31536000",
Date: new Date().toUTCString(), Date: new Date().toUTCString(),
}, },
}); });

View file

@ -174,6 +174,8 @@ export const createServer = (
return null; return null;
}); });
proxy?.headers.set("Cache-Control", "max-age=31536000");
if (!proxy || proxy.status === 404) { if (!proxy || proxy.status === 404) {
if (config.frontend.glitch.enabled) { if (config.frontend.glitch.enabled) {
return ( return (