Architectures
Time to First Byte (TTFB)
First Contentful Paint (FCP), First Meaningful Paint (FMP)
Largest Contentful Paint (LCP)
Time to Interaction (TTI), Total Blocking Time (TBT)
First Input Delay (FID)
Cumulative Layout Shift (CLS)
Full Client-Side Rendering
Client-Side Rendering w/ Prerendering
Server-Side Rendering w/ Rehydration
Static Site Gerneration
Incremental Static Site Regeneration
Server-Side Rendering w/ template engines
Regular Single-Page Application
Regular Single-Page Application
Serve only static files and fetch data through AJAX
Bad, Cost more in indexing (running JS, potential wrong results)
Fastest TTFB (leveraging CDN)
Blank page in the first loading (TTI >>> FCP)
Var 1. generates pre-rendered static HTML for each page and runs as a SPA once a page is loaded.
Longer build-time process
Inflexible for building more content
Static resources that may require more space to place
Not flexible. Works only in a given framework environment
TTI = FCP, Fast like static pages
Gatsby, VitePress
Var 1. generates only the app's shell and serves as a SPA.
Same as Full CSR, but leveraging the static layouts
hack the UX w/ App shell (PWA) (FCP → LCP)
Rehydration = server-side + client-side rendering
provide whole static HTML at the first landing, and runs SPA in coming navigations
Cost Big: Cost more resources for running JS and rendering contents on server-side
e.g. Browser -> CDN & Render Server (Node.js) -> API Server
Most flexible → leverage all possible solutions for rendering (acts as a real server. e.g. layered cache, runtime purging, throttling...)
e.g. Different APIs, Debugging, API calls, Memory Leak...
Complex: One code runs in two environment (Browser, Node.js)
Next.js, Nuxt.js
Serve only static files
theoretically The Best
Inflexible for building dynamic content
build-time JS for rendering, runtime JS as the add-ons
More JS could be added
Simple. could combine rendering & API server as one
e.g. Django = rendering server, API server, JS build-time bundling
Server need to render and serve documents
Coupled with UI and Data (No Separation of Concerns)
Skew. JS Components are more flexible than template engines
--> should consider SPA
Could have no build-time through deployments
e.g. DHH built Hey with fewer JS bundling (https://world.hey.com/dhh/hey-is-running-its-javascript-off-import-maps-2abcf203)
Flexible as SSR Rehydration
Serve as static pages at first loads
Cache Revalidation (no thundering herd problem)
Purge cache on demand (event-driven)
Based on Server-Side Rendering w/ Hydration
3 advantages in one which no one did before:
3. Minimize the API call & rendering cost
2. Ability to keep everything updated / dynamic
1. Instant Performance