also send cache-control

This commit is contained in:
HF 2022-04-05 15:17:01 +02:00
parent f6902ca73c
commit 855a5b426b

View File

@ -45,9 +45,10 @@ export default async (req: Request, res: Response, next) => {
let curEtag = chunkEtags.get(etagKey);
const preEtag = req.headers['if-none-match'];
if (curEtag && preEtag === curEtag) {
if (curEtag && preEtag && preEtag === curEtag) {
res.set({
ETag: curEtag,
'Cache-Control': `public, s-maxage=${60}, max-age=${40}`, // seconds
});
res.status(304).end();
return;
@ -69,10 +70,12 @@ export default async (req: Request, res: Response, next) => {
res.set({
'Cache-Control': `public, s-maxage=${60}, max-age=${40}`, // seconds
'Content-Type': 'application/octet-stream',
});
if (!chunk) {
res.set({
'Content-Type': 'application/octet-stream',
});
res.status(200).end();
return;
}