careerbydoing
← Web development

Web development

Computed once, or every time

About 4 min if you have seen this material before, 15 min or so if it is new to you.

Background
The last piece of the picture is *when* code runs. A page whose output is identical for every visitor can be rendered once, when the project is built, and served as a finished file forever after. A page whose output depends on the request (who is logged in, which problem was asked for) must be rendered per request. This is Whether a page's HTML is computed once at build time or freshly on every request., and it is the same trade as precomputing a lookup table versus evaluating a function on demand: cheaper per use, but only valid when the answer does not vary. Next.js decides this per route and prints the verdict in the build output. A circle marks a static route, an f marks a dynamic one. Reading that output is the quickest way to catch a page that has accidentally become dynamic and is now doing work on every single visit.
Here is this project's real build output:
Route (app)
┌ ○ /
├ ○ /_not-found
└ ƒ /problems/[domain]/[slug]

○  (Static)   prerendered as static content
ƒ  (Dynamic)  server-rendered on demand
The homepage builds its list by reading the content directory from disk. If 100 visitors each load the homepage once, how many times does that directory get read?

Past 40 min on this? That usually means a missing prerequisite rather than a lack of effort — worth reading up before pushing further, starting with Partial prerendering (Next.js docs).

Want to go deeper?