Do API routes cache their responses?
Unanswered
Griffon Nivernais posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Griffon NivernaisOP
Writing an API server in Next (for ease of use, refactor soon) and wanted to know if API routes cache their responses provided I have them setup through Nginx.
3 Replies
![Avatar](https://cdn.discordapp.com/avatars/572329183334891520/3ea2e2e134a2327e2b8a7738876a17b5.webp?size=256)
fuma 💙 joulev
API Routes, are you referring to Pages Router one? If yes, they are not cached. Only
GET
route handlers (in App Router) are cached by default.![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Griffon NivernaisOP
How would I go about setting this up instead then? The calculations i'm doing are quite heavy and involve point-in-polygon tests over 300 objects.
![Avatar](https://cdn.discordapp.com/avatars/572329183334891520/3ea2e2e134a2327e2b8a7738876a17b5.webp?size=256)
fuma 💙 joulev
1. Use Next.js's built-in cache
Change it to a
2. Your own cache
Use Redis or your own in-memory cache implementation, this won't depend on any Next.js built-in features.
Change it to a
GET
route handler, the response will be cached at build time [(under some conditions)](https://nextjs.org/docs/app/building-your-application/routing/route-handlers#caching).2. Your own cache
Use Redis or your own in-memory cache implementation, this won't depend on any Next.js built-in features.