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.

Unexpected behaviour in project build

Unexpected behaviour in project build

Now, let's practically see how the caching is done in the current application. We will run the application in production mode, that is, we will perform the build and run the production build on the server. So let me open the terminal and type in the command npm run build and enter. So it is creating a build. And it is done now. To start the app, we'll use the npm start command instead of npm run dev. Let's do that. And it's running on the localhost 3000. Now let's check the browser. So it looks normal. But let's say if I try to delete a product, for example, orange, then as you see, it is not getting removed from the products page. However, if we check it in the database, then here the orange is deleted. So why is this happening? Well, the caching features of Next.js are responsible here. When we run the application in production mode, Next.js uses all its caching features to gain the optimal performance. So what exactly happened is, when we executed the npm run build command. At that…

Contents