What is CDN Caching?
CDN caching stores copies of content at geographically distributed edge locations. Requests can be served near their recipients without repeatedly retrieving the same representation from the origin.
How CDN Caching works
A CDN maps a request to an edge location and attempts to reuse an object stored there or in an intermediate shield. On a miss, the network retrieves the representation from an upstream cache or origin, then stores it according to freshness and eligibility rules. Each location fills its own cache, so an object that is warm in one region can still be a miss in another, and an unpopular object can be evicted before it expires. For media, immutable segments and derivatives can receive long lifetimes, while manifests and authorization-dependent responses usually need shorter or more selective treatment.
Key facts
- A stream’s manifest and its media segments need different lifetimes. In HLS, a live media playlist is replaced by a new version with at least one new segment about once per target duration (RFC 8216 requires it no sooner than half and no later than one and a half times that duration), so an edge that keeps the playlist longer hides new segments from players. A playlist marked
VODmust not change and can be cached like a static file. Segments are fetched separately from the playlist, each under its own URL or as a byte range of a larger file, and can take long lifetimes provided the packager never changes the bytes behind a published URL, which the specification does not itself guarantee. Apple’s draft second edition of HLS recommends, in its low-latency server profile, caching ordinary playlist responses for half the target duration and usingCache-Controlto communicate the lifetime. - The cache key decides which requests share an entry, and its default differs by CDN. Amazon CloudFront’s default key is the distribution’s domain name and the URL path, without query strings, headers, or cookies. Cloudflare’s default includes the scheme, host, and path with query string, plus the request’s
Originheader, so the same URL fetched with and withoutOriginis stored separately. Google Cloud CDN uses the complete request URI for backend services. Requests share an entry whenever their keys are identical, which a default can already cause: under CloudFront’s default, URLs that differ only in the query string receive the same cached response. Put every request value that changes the response into the key and leave out the rest, because a component that varies between requests without changing the response splits the cache and lowers the hit ratio. - For large files, find out how the CDN handles
Rangerequests, because it changes origin load and seek behavior. CloudFront forwards a range it does not hold to the origin, possibly asking for a larger range, and caches the returned part; if the origin does not support ranges, CloudFront receives and caches the entire object. Google Cloud CDN fills its cache with its own byte range requests once it has recorded that the origin supports them, which requiresAccept-Ranges: bytes, a known total length, and bothLast-Modifiedand a strongETag, and it applies a much lower maximum cacheable size when the origin lacks that support. Fastly caches large objects in parts only when Segmented Caching is enabled. An origin that answers range requests correctly is therefore a precondition for caching large media in parts. - Whether a response is eligible for caching is decided separately from how long it stays fresh, and the rule is provider-specific. Cloudflare caches by file extension by default and does not cache HTML or JSON without a rule. Google Cloud CDN’s default mode caches static content types by
Content-Typeand needs explicit directives for HTML and JSON. A response that sets a cookie is not cached by Google Cloud CDN; Cloudflare, depending on its configuration, either leaves it uncached or removes the cookie and caches it. When an expected hit does not happen, read the cache status the CDN reports: on Cloudflare, theCF-Cache-Statusresponse header showsMISSwhen the response was eligible but not in that cache,BYPASSwhen the origin response was not cacheable, andDYNAMICwhen the request was never eligible.
When CDN Caching matters
Configure CDN caching to lower media latency, reduce origin load, and absorb traffic spikes. Poor cache keys or freshness rules can serve incorrect variants or leave users with stale content.
How Transloadit helps with CDN Caching
Transloadit’s Smart CDN puts a CDN cache in front of on-demand processing. Requests to a tlcdn.com URL are delivered by the /tlcdn/deliver Robot, which caches results and serves them from edge locations. On a cache miss the Template’s Assembly runs; on a hit the edge answers without running anything. The Cache-Control values sent by the /file/serve Robot set how long a cached result stays fresh.
The first uncached request for a URL includes source fetching and processing time. Current default lifetimes are listed on the /file/serve page and are not repeated here because they can change.
Sources
- RFC 9111: HTTP Caching (cache keys, storing partial responses, freshness)
- RFC 8216: HTTP Live Streaming, Section 6.2 (how servers update playlists)
- HTTP Live Streaming 2nd Edition (Internet-Draft 22), Appendix B.1: recommended cache lifetimes
- Amazon CloudFront: Understand the cache key
- Amazon CloudFront: How CloudFront processes partial requests for an object (range GETs)
- Cloudflare: Cache keys
- Cloudflare: Default cache behavior (eligibility, default file extensions, request collapsing)
- Cloudflare: Cache responses (CF-Cache-Status values)
- Cloudflare: HEAD requests and Set-Cookie headers (when a response that sets a cookie is cached)
- Google Cloud CDN: Caching overview (cacheable content, cache keys, byte range requests)
- Fastly: Segmented Caching