Skip to content

Tutorial · Performance · Intermediate · 1 min read

Slow server response: where the first second goes

What time to first byte measures, why large sites often respond in over a second, and the caching, database and hosting changes that bring it down.

Before a browser can show anything, it has to receive the first bytes of HTML. Everything that happens before then counts towards time to first byte: DNS lookup, connection and TLS setup, redirects, and the time your server spends building the page. Google's web.dev guidance treats a time to first byte of 0.8 seconds or less as good.

Zenith measures how long your server takes to respond from its own network. It reports a moderate response time above 1,000 milliseconds and a slow one above 2,000 milliseconds. These are lab measurements from one location, so treat them as a signal to investigate rather than as your visitors' exact experience.

The usual causes

  • Pages are rendered on every request even though their content rarely changes.
  • Slow or unindexed database queries, often added gradually as features grow.
  • Calls to other services, such as personalisation, stock levels or analytics, made before the HTML is sent.
  • Redirect chains, for example from http to https and then to www, each adding a round trip.
  • Hosting a long way from visitors with no CDN in front of the origin.

Fixes, in order of impact

  1. Cache full pages at a CDN where content allows, and send Cache-Control headers that let it do so.
  2. Move personalised fragments to the client or to a later request so the main HTML can be cached.
  3. Profile the slowest requests and fix the database queries behind them.
  4. Remove unnecessary redirects and link directly to the final URL.
  5. Stream HTML so the browser can start on the head while the server finishes the body.
Example
Cache-Control: public, max-age=60, s-maxage=300, stale-while-revalidate=600

Glossary

TTFB
Time to first byte: the time from starting a request to receiving the first byte of the response.
CDN
Content delivery network: servers close to visitors that cache and serve your content.

Observed in published reviews

Zenith recorded this problem in these company website reviews.