From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Static to dynamic: Cache control

Static to dynamic: Cache control

Alright, now we did find the issue, but we need the products page to be dynamic, so that it is rendered with the latest data. So let's see what makes a page dynamic and how we can make the products page dynamic. When you have the page in a dynamic route, then it is automatically considered dynamic. This you can see with the product details page in the terminal. It has the lambda sign before it, denoting it is dynamic. Then the second way is by calling a dynamic function or referencing a dynamic variable while the route renders. Here you can use methods like calling the fetch method in a component will also make it dynamic. And last but not the least, you can manually set a page to dynamic by giving route segment config options. These are specifically named variables that you export with a value and Next.js will understand that it is supposed to be dynamic. Let's use this practically to understand better. So in the home page, if I want to make this component dynamic, then I will export…

Contents