Tech

Caching and CDN Strategies for Fast Static Sites

Suggested path: Performance Engineering · View path →

The best request is the request the browser does not need to make again.

Caching is a delivery strategy

A cache is useful because the browser or edge can reuse a response instead of fetching it from the origin again. For a static site, that can remove an enormous amount of repeat network work.

Separate HTML from fingerprinted assets

HTML changes more often than versioned CSS, JavaScript and images. Long-lived assets work best when their URLs change whenever their contents change. A file such as app.8d3f.js can safely be cached for a long time because a new build gets a new filename.

Use cache-control deliberately

For immutable hashed assets, a long max-age with immutable is ideal. HTML usually needs a shorter lifetime so visitors can discover new content. Do not give every resource the same caching policy.

What the CDN actually buys you

A CDN puts cached content closer to users and absorbs repeated requests at the edge. For a globally distributed audience, that reduces round-trip time even when the origin stays in one region. Static sites benefit especially because most page assets can be served without touching the origin.

Beware of stale content

Long TTLs create one trade-off: updates can take time to appear. Fingerprinted assets solve most of this. Change the filename when the content changes, keep the HTML more replaceable, and you can have both aggressive caching and reliable deploys.

A practical static-site policy

HTML:        short cache / revalidate
JS & CSS:    long cache if fingerprinted
Images:      long cache if versioned
Fonts:       long cache if immutable
Sitemap:     revalidate after deploy

The goal is simple: cache aggressively where content can never be stale, and keep the documents that point to those assets easy to refresh.

  • #Performance
  • #Caching
  • #CDN

Latest updates

The four most recent posts across StackSignal.

All posts
Tech

Image Optimization for the Modern Web

A practical image optimization guide covering dimensions, modern formats, responsive images, loading priority and the mistakes that hurt LCP.

1 min read