1 comment

  • Hooman Beheshti

    For web pages, TTFB (like what's measured on is how quickly the first byte of the page is received by the client. This is generally dictated by how quickly the base HTML of the page is served. So, the faster the HTML arrives at the client, the better.

    The best way to do this is to cache the base HTML on Fastly. This will distribute the HTML and when accessing a page, clients will get the HTML from a Fastly cache close to them. That's why has such good TTFB.

    The problem is that most HTML is considered "dynamic." Content management systems often mark HTML pages as non-cacheable (through cache-control headers) or web admins purposely make HTML non-cacheable in order to avoid serving stale content.

    Fastly's instant purging techniques can help this. HTML objects can be marked as cacheable and cached at the edge, just like normal static objects. When they change, a purge command can be issued to purge the object from Fastly's caches, forcing a re-fetch when the page is requested next. This is done instantly, so no stale content will be served.

    There's a good write-up of this here including links to other Fastly resources that can help with making dynamic content caching easier.

    Not all HTML objects are cacheable, so some will still need to go all the way to origin. But, lots of HTML can be cached when instant purging provides a quick and dynamic (pun intended!) way to invalidate it from the cache when things change.

    Comment actions Permalink

Please sign in to leave a comment.