Diagnosing and Fixing Slow TTFB on Static and Jamstack Websites

The Paradox of Slow Static Sites

Static sites (built with Astro, Hugo, or Gatsby) are theoretically capable of delivering sub-100ms response times because HTML files are pre-compiled and served directly from storage.

Yet, developers frequently encounter sluggish Time to First Byte (TTFB) scores exceeding 800ms. Why does this happen, and how can you diagnose the root cause?

1. Common Culprits Behind High TTFB

1. CDN Cache Misses (Cold Starts)

When your hosting provider serves static files from a centralized origin server rather than global edge caches, the first visitor in a region experiences a cache miss that requires a slow round-trip fetch.

2. DNS Resolution Overhead

Using slow, unoptimized DNS providers can add 150ms to 300ms before the browser even establishes a TCP handshake. Moving your DNS to Cloudflare or Route 53 reduces lookup times to under 20ms.

3. Misconfigured Edge Functions / Middleware

If your static site executes heavy serverless functions or edge middleware (e.g., geo-routing, header rewriting, or external API checks) on every request, your static advantages evaporate:

// Anti-pattern: Blocking static response with synchronous external API
export async function onRequest(context) {
  const geoData = await fetch('https://slow-external-api.com/lookup'); // Adds 400ms!
  return context.next();
}

2. Optimization Protocol for Sub-100ms TTFB

  • Enable aggressive edge caching headers (Cache-Control: public, max-age=31536000, immutable).
  • Use HTTP/3 and QUIC protocols for streamlined multiplexed connections.
  • Ensure TLS 1.3 session resumption is active on your edge CDN.

Conclusion

Fast TTFB is the prerequisite for all Core Web Vitals. Discover how my speed optimization services can get your site's TTFB under 100ms.