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.

RQ: Unexpected behaviour in project build

RQ: Unexpected behaviour in project build

Let's discuss a situation. Let's say we have a project and we create the build of that project and run it. Now if I delete one of the items in the project, then the item will get deleted from the DB. However, it is still there in the output. So what's the reason behind that. 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 time, Next.js analyzed all the files and distributed them in two categories, static and dynamic. By default, all the files are considered to be static. So when a file is static, then it is cached at the build time with the interface as well. This means that once the application is built, the page is stored in the cache and whenever that page needs to be rendered, it is taken from the cache instead of re-rendering every time. So, our page will be static. Due…

Contents