Static versus dynamic hosting

What actually differs between a prebuilt site and one rendered per request, and how to choose between the hosting models.

The four models you will meet

ModelWhat runs at request timeFits
Static filesNothing - the file is served as-isDocs, blogs, marketing sites, this tutorial site
Pre-rendered (SSG)Nothing; HTML was built ahead of timeContent sites that need templating at build
Server-rendered (SSR)An application process per requestPersonalised pages, live data, sessions
Serverless / functionsOne isolated function invocationForm handlers, webhooks, light APIs

Static does not mean hand-written HTML. It means the output of a build: a generator reads Markdown or a data structure and writes complete HTML files. The result is cheap, cacheable and has almost no failure surface, because there is no process that can run out of memory mid-request.

Choosing honestly

  • Anything that is the same for every visitor should be static - it is faster and cheaper at any scale.
  • Per-user content (dashboards, carts) belongs on a server or in a function, not in a CDN cache.
  • Static hosting has no server-side secrets: anything you put in the build ends up public in the output.
  • Search ranking favours the model that returns full HTML in the first response; client-side-only rendering risks being indexed later or not at all.
  • A hybrid is normal: static pages for content, a small function for the contact form.
# serving a built directory: the whole static story
server {
  listen 443 ssl http2;
  server_name example.com;

  root /var/www/site/dist;
  index index.html;

  location / {
    try_files $uri $uri/ =404;          # serve files, never a PHP-style handler
  }

  location /assets/ {
    add_header Cache-Control "public, max-age=31536000, immutable";
  }
}
💡
A static host cannot execute code, so it cannot be compromised into running yours. That is the real security argument, and it is worth more than the speed argument.

FAQ

Can a static site have a search box or comments?
Yes - either with a third-party service that runs the logic elsewhere, or with a serverless function you call from the page. The site stays static; the dynamic part is a separate service.
Is static hosting cheaper?
Usually free or a few dollars a month even at high traffic, because serving a file from an edge cache costs a fraction of running a process per request.

Build and deploy workflows How a CDN serves your content

Last refreshed 2026-09-18.