Skip to content
Frontend

Content delivery done right: caching, CDNs, and headers

Practical guidance to configure long-lived caching, immutable assets, and CDN rules for blazing-fast Astro sites.

Modular Shift Team
Modular Shift Team
Platform Engineering

Cache the right things for the right time

Astro’s static output is perfect for aggressive caching. Let assets live at the edge for a year, while HTML gets short, sensible TTLs and quick revalidation.

  • cache-control: public, max-age=31536000, immutable — for hashed JS/CSS/images
  • cache-control: public, max-age=300, stale-while-revalidate=86400 — for HTML
  • etag and last-modified — enable conditional GET and lighter revalidation
  • content-encoding: br — serve Brotli where supported

CDN rules that pay off

  • Normalize URLs: enforce trailing slashes or not, lowercase paths
  • Compress at edge: Brotli for text assets, set proper vary headers
  • Edge cache HTML when it’s safe; purge by tag on content updates
  • Enable HTTP/2 and HTTP/3; use TLS 1.3

Image delivery

  • Serve AVIF/WebP with fallbacks; include accept negotiation or build‑time formats
  • Always ship srcset + sizes so clients choose the right bytes
  • Use content hashes for long‑lived caching via the CDN

Verify and monitor

  • WebPageTest for repeat‑view caching behavior
  • Lighthouse + PSI for Core Web Vitals
  • CDN analytics to spot cache misses and large responses

Conclusion

Good caching is configuration, not complexity. Lock down assets for the long haul and keep HTML fresh with quick revalidation. The result: faster pages, lower bills.

Want a review of your headers and CDN setup? Request a quick audit.

Start Your Audit →

The rebuild was transformative — faster pages, easier content updates, and automation that saves hours every week.

Alex M.
Digital Manager — Non-Profit Organisation

Our leads are now routed instantly to the right team member, and site speed is no longer holding us back in search rankings.

Sophie R.
Head of Marketing — Franchise Network

Let’s build something faster, smarter, and static‑first

Your website should work as hard as you do.