Crawlsonar
Performance

TTFB, caching and compression

Also known as: Time to First Byte, Cache-Control, CDN, Brotli, gzip

How long the server takes to start answering (TTFB), and the three levers that make every page faster for everyone: caching, a CDN and compression.

In plain English

Before a browser can show anything, it has to wait for the first byte of the answer — that wait is TTFB. Everything else (images, scripts, the main content) queues behind it, so a slow first byte makes the whole page late. Think of a restaurant: the kitchen can be brilliant, but if nobody takes your order for two minutes, the meal is slow.

Caching means answering repeat questions from memory instead of cooking again; a CDN means having a kitchen in every city instead of one far away; compression means packing the meal smaller so it travels faster. All three are server settings, not content changes — usually the cheapest speed-up a site can get.

How to fix / set it up

  1. Run the Speed Test to see TTFB, DNS/TLS timing, compression and whether a CDN is in front.
  2. Put a CDN in front of the origin and set Cache-Control: public, s-maxage=…, stale-while-revalidate=… on pages that are the same for everyone.
  3. Enable Brotli (or gzip) for all text responses at the CDN or web server.
  4. Move the application and its database into the same region; add an application cache for slow queries.

Speed TestCore Web Vitals Checker

The technical detail

TTFB under ~800 ms is good at the 75th percentile; over 1.8 s is poor. It includes DNS, TLS and the server's own think time, so a slow origin in one region hurts every visitor elsewhere — put the app where the data is and the edge where the users are.

Cache-Control drives it: max-age for browsers, s-maxage for shared caches/CDNs, stale-while-revalidate to serve a cached copy while refreshing in the background; ETag/Last-Modified make revalidation cheap. Compress text with Brotli (or gzip as a fallback) — HTML, CSS, JS, JSON and SVG typically shrink 70–85%. Never cache personalised responses publicly.

FAQ

Is a CDN only for big sites?

No — it's usually free or a few dollars, and it helps small sites most because they have a single origin far from most visitors.

Can caching show visitors stale content?

Only for as long as you allow. Short `s-maxage` with `stale-while-revalidate` keeps pages fresh within seconds while still serving from cache; purge on publish if you need instant updates.

Related

← All topics in the knowledge base