Caching an entire API route for 5 minutes

Hi everyone! I was wondering if my Next.js API route (using the app directory) can be cached using Vercel as a server-side layer. So, for example, if my api route returns something like:
createdAt: new Date
createdAt: new Date
I would like to see the same date for 5 minutes. As of right now I tried following this: https://nextjs.org/docs/app/building-your-application/data-fetching/revalidating#on-demand-revalidation Which does seem to be working if I'm using fetch, but it doesn't if I put export const revalidate = 60 in my API route. Thank you in advance to anyone who's willing to help! Cheers.
Data Fetching: Revalidating
Learn about revalidating data in Next.js using Incremental Static Regeneration.
1 Reply
sean
seanOP2y ago
Update: I just tried to return the header 'Cache-Control': 's-maxage=300, stale-while-revalidate' This seems to be working but only client-side. I would need exactly the same but also server side
Want results from more Discord servers?
Add your server