Caching needs an update strategy
Long-lived caching is safe for files whose URL changes when their content changes. HTML often uses shorter caching because it points to the newest versioned assets and must update promptly.
A CDN serves from nearby locations
A content delivery network can cache images, scripts, and other public responses at edge locations. It does not remove the need for correct headers, secure origins, or a plan for invalidating changed content.
A familiar example
Shipping a new stylesheet
- The build creates a stylesheet filename containing a content hash.
- Browsers cache that immutable file for a long time.
- A new release creates a different filename, so the updated HTML points to the new style without guessing whether an old cache is stale.
What to remember
- Cache reusable work deliberately.
- Versioned asset URLs make long caching safer.
- A CDN improves delivery but does not decide update correctness for you.