feat(cache): add cacheConfigSetter & cacheControlMiddleware by #90

This commit is contained in:
Ritesh Ghosh
2024-12-24 17:07:35 +05:30
parent d939222757
commit 5f1f2167df
2 changed files with 35 additions and 15 deletions
-15
View File
@@ -1,15 +0,0 @@
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;