If your live stream or videos are in HLS format, they can be proxied to end users via CDN servers to speed up the loading time. It’s possible because the HLS protocol is based on HTTP. It’s cached and distributed via CDNs like regular static files.
You can use a CDN service for streaming if the following conditions are met:
If your stream is in another format (RTMP, SRT, MP4), use the Streaming service.
Send us a request to activate the streaming workflow for the CDN at email@example.com or the chat window in the bottom-right corner of our website. Please specify your ID in the request, so we can identify your account. You can find it on the main page of your control panel.
In the request, provide the following information:
We’ll notify you when we activate the workflow. After that, you’ll be able to configure streaming.
Create a CDN resource according to the "Create a CDN resource for only static files" guide.
Set short-term cache settings for the following types of HLS video files:
Firstly, the browser requests a playlist (.m3u8) and then playback segments (.ts) in the order they’re listed in the playlist.
Segments (.ts) should be cached for 1 minute. This period is a bit longer than the length of each video segment. It’s necessary for end users with a slow internet connection. When they receive the playlist with the list of the segments from the CDN server, it may already be outdated, and the origin of the CDN resource may have a new playlist with current segments. So, if segments are cached for less than 1 minute, the end user’s browser sends a request to the outdated segments from the origin, and it’ll receive a 404 error because these files don’t exist.
Playlists (.m3u8) should be cached for 1–2 seconds. This period should be very short, so that end users don’t receive the playlist with old segments from the cache.
You can set cache settings either on your origin (in the Cache-Control HTTP header) or in the control panel.
Change your domain address URLs from the origin to your CDN domain name. For example,
http://domain/playlist.m3u8`` (a stream URL from origin) → http://cdn.domain/playlist.m3u8``` (a stream URL from the CDN).
You can check your stream on any player that supports online HLS streaming (for example, VLC).
If you’re going to deliver videos (VOD), go to the next step. To reduce the load on CDN servers, turn on the Live streaming preset. It allows configuring file caching through RAM instead of through hard drives.
To do this, go to the CDN resources list. Click the three dots next to the resource and choose Turn on LIVE STREAMING preset.
Was this article helpful?
Learn more about our next-gen CDN