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.

Time-based cache control

Time-based cache control

Now, let's see more ways of performing cache control. First, let's have a look at how we can implement time-based caching, that is, how to make the page re-render on specific time intervals. As discussed earlier, we can make the page dynamic by defining the route segment config options, one of which was the dynamic keyword that we used in the last lecture. And just like the dynamic variable, there is another keyword that you can use called the revalidate. The revalidate is used to set the revalidation time that is after how long should the server re-render a particular page. So in the code, instead of dynamic, if I say export const revalidate is equal to zero. Now this means that constantly the page will be ready for re-rendering. So the page will be re-rendered with the latest data whenever reloaded. Let's rebuild the project and check. I'll start the app. And now let's add another product. And the new product is rendered immediately. Now let's say if I had set the value of…

Contents