Server-side rendering and caching
Currently, we are rendering the pages on each request, which is good if the data changes frequently; otherwise, it might increase the loading time and server costs because rendering on the server is a compute-intensive operation.
It works as follows:
- User1 requests a page.
- The server returns the cached version of the page and returns it.
- During that request, Next.js is triggered to regenerate the same page with the latest data.
- User2 requests a page.
- The server returns the new version of the page.