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.

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.
Recommended headers
cache-control: public, max-age=31536000, immutable
— for hashed JS/CSS/imagescache-control: public, max-age=300, stale-while-revalidate=86400
— for HTMLetag
andlast-modified
— enable conditional GET and lighter revalidationcontent-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.
Related posts
CMS choices for Astro: headless, hybrid, or markdown?
Trade-offs and setup tips for content teams who want speed without losing editorial workflows.
Image pipelines in Astro: sharp, CDN, and next‑gen formats
Serve beautiful images fast with AVIF/WebP, responsive sizes, and caching that actually works.
Designing content models that scale
How to model pages, posts, and modular blocks so teams can move fast without breaking consistency.