Next.js Discord

Discord Forum

Caching and pagination

Unanswered
Indigo Bunting posted this in #help-forum
Open in Discord
Indigo BuntingOP
I have a webshop, which has a category/[categoryId] page, which is a server component. I have also set up an API route, from which the data is fetched, with { next: { revalidate: 1200 } }.

However, as a category can have many products, I added pagination using search params, i.e. ?page=2 etc. This opts the route in for dynamic rendering, and while it is still relatively fast (less than 1 second), is there no way to cache the entire result and serve it even faster? It feels like this should be possible, as while I am using searchParams, category/[categoryId]?page=2 should serve the same result to multiple different users anyways.

Am I missing something, or should I use some other approach?

0 Replies