Server-Side Rendering vs Static: Choosing Wisely
Static generation and SSR compared on cost, caching, freshness, failure modes, and personalization — plus a decision framework and migration path.
By Velloreth
The choice between static generation and server-side rendering gets framed as a performance debate, and performance is almost the least interesting part of it. Both can be fast. Both can be slow.
The real differences are when the HTML is created, who is allowed to see different HTML, and what happens when things break.
What each one actually does
Static (SSG): HTML is generated at build time. Every visitor receives the same files, typically from a CDN edge cache that never executes your code. Nothing runs when someone loads a page.
SSR: HTML is generated per request, on a server that runs your application code, renders the page, and sends the result. The content can depend on the request — cookies, headers, query parameters, live data.
Client-side rendering is the third option people conflate with SSR: the server ships a shell, JavaScript builds the page in the browser. It is a different trade-off entirely, and it is not what “SSR vs static” is about.
| Static | SSR | |
|---|---|---|
| HTML generated | Build time | Request time |
| Response varies per visitor | No | Yes |
| Hosting | Any file host / CDN | Runtime required (Node, Cloudflare Workers, etc.) |
| Cost model | Fixed, effectively free at any traffic | Scales with requests |
| Content freshness | Rebuild to update | Always current |
| Failure moment | Build time (CI) | Request time (users watching) |
| Caching | Free and trivial at the edge | You must define and enforce it |
| Personalization | Client-side only | Native |
The difference that actually decides it
Ask one question: does the HTML need to be different for different requests?
If the answer is no — a blog, documentation, a marketing site, a portfolio, most of an e-commerce catalog — then SSR is paying per-request compute to produce output that is identical every time. You are renting a kitchen to re-cook the same meal.
If the answer is yes — a dashboard, an authenticated area, search results, previews behind a token, prices for a specific customer — then static cannot do it at all, and the only question is how much of the site really needs to be dynamic.
Most projects are not one or the other. They are a mostly-static site with a handful of dynamic routes: the blog is static, the account page is SSR. Frameworks support this directly.
How Astro frames it
Astro ships with output: 'static' as the default. Every page is prerendered unless a route opts out:
// astro.config.mjs
export default defineConfig({
output: 'static', // the default; no need to write it
});
---
// src/pages/search.astro
export const prerender = false; // this route renders on demand
---
That opt-out is the vestige of what used to be a separate hybrid mode — Astro 5 merged hybrid into static, and as of Astro 6 configuring output: 'hybrid' is an error telling you to use static instead. The current model is two modes:
static— prerendered by default;export const prerender = falseper route for the dynamic ones.server— rendered on demand by default;export const prerender = trueto keep specific routes static.
Both server-rendered modes need an adapter (@astrojs/cloudflare, @astrojs/node, and friends) that knows where your code runs.
The practical implication: you can start fully static, add an adapter later, and convert one route at a time as requirements appear. There is no migration cliff.
Cost and scaling
Static hosting is close to free because serving a file from an edge cache costs the provider almost nothing. Traffic spikes are a non-event — there is no origin to overwhelm.
SSR bills for work. Every request runs your code: CPU time, memory, cold starts on serverless platforms, and a scaling story you need before launch rather than after. None of this is prohibitive; it is just a real cost that exists only if you chose SSR.
The trap is doing SSR for content that did not need it. You inherit runtime cost and operational complexity — deployments that can break at 2am, environment variables that differ between build and run, and secrets management — in exchange for producing HTML you could have baked once.
Caching: free versus earned
This deserves its own section because it is where static quietly wins.
With static, caching is the default posture. Assets get content-hashed filenames and immutable cache headers; HTML can be cached aggressively at the edge. There is nothing to invalidate except when you deploy.
With SSR, every request reaches your code unless you intervene. Good SSR setups cache heavily anyway, but those are decisions you make, document, and can get wrong. A missing cache header on an SSR route is a bill and a latency penalty that would not exist in static mode.
What that decision looks like concretely:
# product page: personalized price, but the shell is cacheable
Cache-Control: private, no-store
# public doc page rendered on demand: cache at the edge for 5 minutes
Cache-Control: public, s-maxage=300, stale-while-revalidate=3600
# hashed asset: cache forever
Cache-Control: public, max-age=31536000, immutable
Get these wrong in one of two expensive directions: too short, and you pay for renders you did not need; too long, and users see stale personalized or permission-sensitive data. The private versus public distinction is the one to be paranoid about — marking an authenticated response public is a real security bug, not just a performance mistake.
Astro has no built-in incremental regeneration. If fresh static content matters, your freshness loop is: rebuild, deploy, purge CDN cache — fast on modern platforms, but it is a pipeline, not an implicit behavior.
Failure modes
Ask where each architecture fails:
- Static fails at build time. A broken page fails CI, blocks the deploy, and nobody sees it. This is the ideal failure moment.
- SSR fails at request time. A bad environment variable, an exhausted rate limit, a downstream API timeout — all discovered by users.
This asymmetry is the most underweighted argument in the whole decision. Static converts runtime failures into build-time failures, and build-time failures are categorically cheaper.
The counterpoint: static fails stale. If the content behind the page changes and your build does not run, the site keeps serving the old truth. SSR never goes stale — it goes down instead. Which failure you prefer depends on the content: docs can be hours old; an order status page cannot.
SEO, honestly
Both modes produce HTML that crawlers read. The SEO argument for static is not that SSR is invisible to search engines — it is that pre-rendered HTML is the boring, guaranteed path:
- No dependency on the crawler’s JS rendering budget or capacity.
- No flash of incomplete content if a render pipeline hiccups.
- Faster first response from edge caches, which correlates with better Core Web Vitals.
SSR is perfectly indexable and is the right choice when the content itself must vary — paginated results behind filters, localized copy resolved server-side, pages behind authentication that still need to exist as HTML.
Where SSR does not help is a page whose HTML is identical for every crawler and user. If you are adding a server to “improve SEO” while serving the same markup to everyone, you have added cost without changing what gets indexed.
Interactivity is a separate decision
A persistent source of confusion: how much JavaScript the browser runs has nothing to do with how the HTML was produced.
Astro’s island architecture makes this explicit — a static page can hydrate one interactive component while the rest ships as HTML. An SSR page can also ship no client JavaScript at all. Conversely, a fully static page can drown in client-side rendering.
So the framework is two independent axes:
- Where is HTML generated? Build time (static) or request time (SSR).
- Where does interactivity run? Client-side components, islands, or server-driven.
Choosing one axis does not force the other.
A decision framework
Run through the questions in order:
- Is the content identical for all visitors? Yes → static. No → dynamic route needed.
- Does it change per request or per user? Per user (auth, preferences) → SSR. Per deploy (published posts) → static with a rebuild pipeline.
- Does it change many times a minute? If yes and it is user-specific, SSR with caching at the right layer. If yes and global, consider polling or client-side fetch after first paint instead of SSR.
- Can a stale version harm anyone? Prices, inventory, permissions → must not be stale. Articles, profiles, documentation → stale is tolerable.
- Who operates the runtime? A server you own is a commitment: monitoring, scaling, secrets, incidents. If nobody on the team wants that, bias to static.
- How much of the site is actually dynamic? If it is three routes out of a thousand, the answer is static-by-default with per-route SSR — not an SSR site.
| Typical page | Right default |
|---|---|
| Blog post, docs page, landing page | Static |
| Marketing site with i18n | Static (build per locale) |
| Search results, filters | SSR or client-side fetch |
| Dashboard, account area | SSR |
| Cart and checkout | SSR |
| Product listing | Static + client updates, or SSR with CDN caching |
| Feed that updates constantly | Client-side polling on a static shell |
Starting static, adding SSR deliberately
The migration path that avoids both extremes:
- Ship static. Get the content, performance, and deployment story right first. For a content site, this may be the entire project.
- Add an adapter when a route needs it. Install the adapter, switch to
output: 'server'if most routes are now dynamic — or keepstaticand setprerender = falseon the few that are not. - Mark dynamic routes explicitly so nobody is surprised:
export const prerender = falseat the top of the file is a readable flag in code review. - Set cache headers before launch, not after the first bill. Decide per route: what is cacheable, for how long, and who purges it.
- Re-check the decision yearly. Requirements drift toward dynamic; habits drift toward comfort. The flag at the top of each route makes the current state of the union visible.
The site you are reading is a static Astro build on Cloudflare Pages — every page prerendered, no server, HTML at the edge. It is the correct choice precisely because nothing about a blog post depends on who is asking. The day a page needs to know that, it gets prerender = false and the rest of the site does not notice.