Remove compression from Express, add CacheHeaders middleware.

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface
2024-04-23 20:47:47 +01:00
parent 90500b88af
commit c698187cdf
3 changed files with 21 additions and 3 deletions

View File

@@ -0,0 +1,10 @@
import { NextFunction, Request, Response } from "express";
export function setCacheHeaders(req: Request, res: Response, next: NextFunction) {
if (res.cacheType && res.cacheSecs) {
const cacheCtlHeader = `${res.cacheType}, max-age=${res.cacheSecs}`;
res.setHeader('Cache-Control', cacheCtlHeader)
}
res.send();
}

View File

@@ -8,5 +8,10 @@ declare global {
export interface Request {
isAuthed: boolean;
}
export interface Response {
cacheType: string;
cacheSecs: number;
}
}
}