This repository has been archived on 2026-07-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
aniwatch-api/src/config/cacheControlMiddleware.ts
T
2024-12-23 03:27:43 -04:00

16 lines
489 B
TypeScript

import type { MiddlewareHandler } from "hono";
// Define middleware to add Cache-Control header
const cacheControlMiddleware: MiddlewareHandler = async (c, next) => {
const sMaxAge = process.env.ANIWATCH_API_S_MAXAGE || "60";
const staleWhileRevalidate = process.env.ANIWATCH_API_STALE_WHILE_REVALIDATE || "30";
c.header(
"Cache-Control",
`s-maxage=${sMaxAge}, stale-while-revalidate=${staleWhileRevalidate}`
);
await next();
};
export default cacheControlMiddleware;