Why does a statically generated website often load faster than one that renders pages on every request?
Short answer
Since the HTML for a statically generated page was already built ahead of time, the server, or often a content delivery network located physically close to the visitor, can send the finished file immediately, without spending any time computing anything at the moment of the…
Advertisement
AModel answer
Since the HTML for a statically generated page was already built ahead of time, the server, or often a content delivery network located physically close to the visitor, can send the finished file immediately, without spending any time computing anything at the moment of the request.
Example
// Once built, this page is just a plain HTML file, ready to serve instantly // No server computation is needed when a visitor requests it // dist/about/index.html
Real-world example
A company's marketing site, built entirely with static site generation, consistently loads in under half a second for visitors around the world, since every page is served instantly from cached files close to each visitor's location.
Likely follow-ups
- What role does a content delivery network play in making static sites load fast globally?
- Are there any downsides to relying entirely on static site generation?
Related topics