Skip to content

Commit

Permalink
Merge pull request #242 from sametcodes/239-implementing-caching-on-t…
Browse files Browse the repository at this point in the history
…he-view-api

fix: applied cache_time variable to the cache-control directive
  • Loading branch information
sametcodes authored Mar 21, 2024
2 parents ae52627 + 69a61ee commit c0d7c04
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion middlewares/api/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export const setCacheControl = (
query: { cache_time, _vercel_no_cache },
} = res.locals;

res.setHeader("Cache-Control", "max-age=60, stale-while-revalidate=2592000");
res.setHeader(
"Cache-Control",
`max-age=${cache_time}, stale-while-revalidate=2592000`
);
if (_vercel_no_cache === undefined) {
res.setHeader(
"CDN-Cache-Control",
Expand Down

0 comments on commit c0d7c04

Please sign in to comment.