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/cache_control_middleware.ts
T

16 lines
463 B
TypeScript

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