Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Specify cache lifetime on a CDN resource or origin
sidebarTitle: Configure CDN caching
ai-navigation: Configure CDN cache lifetime using Origin controlled or CDN controlled modes with Cache-Control headers (max-age parameter) in Apache .htaccess or Nginx nginx.conf, or set Default cache expiry in the CDN control panel to control how long files are stored in CDN servers before revalidation via ETag comparison.
ai-navigation: Configure CDN cache lifetime with origin or CDN controlled settings, advanced caching rules, video TTL guidance, and cache header checks.
---

Files cannot be stored in the CDN servers' cache indefinitely. The CDN caching feature allows setting how long requested files from your origin server will be stored in the CDN server's cache. If end-users request these files, they will be loaded from the cache without additional requests to the origin server, reducing delivery time, financial spending, and the origin server load.
Expand Down Expand Up @@ -228,5 +228,9 @@ X-Cached-Since: 2023-02-23T14:33:07+00:00 | The time when the file was cached in



## Video cache recommendations

Video files, VOD or Live, need different cache lifetimes by file type. Cache segments and single-file MP4 content longer, while keeping manifests short so players receive fresh live and playlist updates.

For video-specific values, apply the [caching rules](/cdn/getting-started/create-a-cdn-resource/create-a-cdn-resource-for-video-streaming#step-4-configure-caching-rules) used when creating a CDN resource for video streaming. They include recommended TTLs for MP4, HLS, MPEG-DASH, live manifests, and segment files.

31 changes: 29 additions & 2 deletions cdn/cdn-resource-options/optimize-large-file-delivery.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,35 @@ Large File Delivery Optimization can be configured in the Resource Settings and
* Large File Delivery Optimization will be applied to all contents in the CDN resource, which could lead to an increased load on the origin. Therefore, consider activating [Origin Shielding](/cdn/cdn-resource-options/general/enable-and-configure-origin-shielding) before using this feature, or make any updates during off-peak hours.
* Remember to [purge the resource cache](/cdn/clear-cdn-resource-cache-by-url-pattern-or-all) after enabling Large File Delivery Optimization.
* Large File Delivery Optimization cannot be used in conjunction with [Fetch Compressed](/cdn/cdn-resource-options/compression/configure-fetch-compression), [Gzip Compression](/cdn/cdn-resource-options/compression/configure-gzip-and-brotli-compression#gzip), and [Brotli Compression](/cdn/cdn-resource-options/compression/configure-gzip-and-brotli-compression#brotli) within the Resource Settings or within the same rule.


* **HLS and MPEG-DASH don't need slicing** — those streams are already split into small segments that the CDN caches individually.


## Example of large file slicing

Example of a video file which is a progressive MP4 of several GB. CDN fetches the file from origin in fixed-size chunks using HTTP Range requests, caches each chunk independently, and serves the requested byte range to the viewer.

When a viewer requests a byte range of a large file, the CDN maps it to the 10 MB chunk(s) that contain it, fetches only those chunks from origin (through the shield), caches them, and assembles the response:

```
Viewer requests bytes 0–1 MB of movie.mp4 (a 2 GB file)
┌───────────┐ needs chunk #1 (bytes 0–10 MB) → cache MISS
│ CDN edge │
└─────┬─────┘
│ Range: bytes=0-10485759
┌───────────┐ chunk cached? no → one Range request to origin
│ Shield │ ───────────────────────────────►┌──────────┐
└─────┬─────┘ ◄──────── 10 MB chunk #1 ───────│ Origin │
│ caches chunk #1 └──────────┘
┌───────────┐
│ CDN edge │ caches chunk #1, returns bytes 0–1 MB to viewer
└───────────┘

Later: viewer seeks to bytes 1-2 MB or 2-3 MB → data is taken from the same already cached 0-10 MB chunk #1.
```

## Configuration steps

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Optimize caching for video delivery:
2. Enable **"Always online"** with these settings:
- Check **error** (serve stale cache if origin returns errors)
- Check **timeout** (serve stale cache if origin times out)
- ?? **Uncheck "updating"** (important - conflicts with internal optimizations)
- **Uncheck "updating"**

Why enable Always online?
- Protects viewers from origin failures
Expand Down Expand Up @@ -194,7 +194,7 @@ Optimize caching for video delivery:
2. Enable **"Always online"** with these settings:
- Check **error** (serve stale cache if origin returns errors)
- Check **timeout** (serve stale cache if origin times out)
- ?? **Uncheck "updating"** (important - conflicts with internal optimizations)
- **Uncheck "updating"**

**Why enable Always online?**
- If origin goes down, viewers can still watch cached videos
Expand Down
Loading
Loading