Set correct Cache-Control headers, use versioned URLs, purge by tag not by URL, and don't cache what you can't invalidate.
A CDN that helps, not hurts
Cache-Control is the contract
public, max-age=31536000, immutablefor hashed assets.no-storefor private data. The CDN obeys the header.Versioned URLs
/app.css?v=1234or/app.a1b2c3.css. When you deploy, the URL changes, the CDN sees a new resource.Purge by tag, not by URL
Tag assets with their deployment ID.
purge tag:release-42is instant; purging URL-by-URL takes minutes.Stale-while-revalidate
Serve stale content while fetching fresh in the background. Users never wait; the cache updates on its own.