Static versus dynamic site

  • Standard term

A static site serves pages built ahead of time, the same file to every visitor. A dynamic site computes some of its response when each request arrives. Many sites mix both.

A static page is already a file, so a content-delivery network (computers that keep copies near visitors) can hand it out with no code running, which keeps it fast and cheap. Reading a database or checking who is signed in takes code running at request time, so anything personal needs a dynamic part.

Where you’ll meet it

Your portfolio is a static site your coding agent built. You ask it to add a list of your latest blog posts. It replies that the list will change only when the site is rebuilt, and offers to rebuild every night or to load the posts fresh on each visit.

What to do

If you publish through this site, have the agent rebuild it with each new post, and the site stays static. If your posts go up on another platform, a nightly rebuild can leave the list a day behind, while loading on each visit shows each new post at once.

Easy to mix up

Does it need a server during the visit?
Static versus dynamic siteInteractive page
Dynamic: yes, some code there has to runInteractive: no, a static page's scripts can handle it in the browser

Check yourself

Your static recipe blog needs a contact form that emails you through a mail service. The service gives you an account key to send with. Where should the key live?

Go deeperFrameworks let each page choose, including a middle option between the two

Frameworks make the choice per route. Between built-once and rendered-per-request sits a page that is served as a stored file and regenerated in the background after a set time or when its content changes, so it stays fast while drifting only a little out of date. Next.js calls this incremental static regeneration.

A static file has little that can break. Dynamic routes add a running program, a data store, and permissions to manage, and a slow database slows every page that reads from it. Serverless and edge functions, small pieces of code a platform starts on demand, give request-time work without a machine you keep running.

Practice Build Basics

Or take the learning quiz on a mix of every set