What is Just-in-Time Encoding?
Just-in-time encoding creates a requested media rendition on demand instead of precomputing every resolution, codec, or quality variant. The result may then be cached for later requests.
How Just-in-Time Encoding works
An on-demand media service resolves a rendition request into a deterministic transform specification, checks a derivative cache, and schedules compute only on a miss. The first response may block, return a placeholder, or complete asynchronously, depending on the delivery contract. Subsequent viewers can reuse the stored output if source identity and transformation parameters match. This design moves rendition selection closer to delivery, while making cache correctness, request coalescing, and resource admission central workflow concerns.
Key facts
- 1A safe derivative key includes immutable source identity, every transform parameter, output format, and encoder or preset version; omission can serve the wrong cached bytes.
- 2Request coalescing lets concurrent misses for the same rendition share one encode, preventing a popular uncached asset from triggering duplicate compute work.
- 3Negative caching and bounded retries are important for invalid sources or unsupported transforms; otherwise every request can repeat the same expensive failure.
When Just-in-Time Encoding matters
This approach reduces storage and avoids generating unused variants, but the first request incurs encoding delay and compute cost. Capacity and caching policies must prevent traffic spikes from overloading encoders.
Common use cases for delivery
These examples cover delivery broadly, not specifically Just-in-Time Encoding.
- Serving image, audio, video, and document derivatives to a geographically distributed audience.
- Protecting private assets worldwide with expiring or signed requests.
- Reducing repeated processing and origin traffic by caching deterministic results.
Working with delivery
This guidance covers delivery broadly, not just Just-in-Time Encoding.
A client requests an asset using a URL or playback manifest. A delivery layer evaluates authorization and cache state, serves a cached response when possible, or retrieves the asset from its origin before forwarding and optionally caching it.
Delivery choices determine more than download speed. Cache keys, origin behavior, authorization, geographic routing, invalidation, and egress cost decide whether an asset is fast, current, and available to the right audience.
What you gain
- Edge caching places frequently requested assets closer to viewers.
- Explicit cache and authorization rules reduce avoidable origin work.
- Multiple delivery variants let clients request an asset suited to their context.
What it costs
- Long cache lifetimes improve hit ratio but make replacement and invalidation more difficult.
- Signed access protects private media but adds key management, clock, and cache-partitioning concerns.
- More variants improve client fit while increasing storage, cache fragmentation, and operational complexity.
Before production
- 1Define cache keys, cache lifetime, invalidation, and authorization behavior explicitly.
- 2Measure time to first byte, cache-hit ratio, egress, and behavior after an origin failure.
- 3Test signed and unsigned requests at the CDN edge, not only against the origin.