Prefetch M3U8
This article will provide a detailed introduction on how to achieve M3U8 pre-warming through EdgeOne, systematically bypassing the cache penetration issue during the premiere phase, ensuring that user requests can directly obtain complete resources from the nodes, thereby improving access quality.
Note:
Background Introduction
For streaming media services using M3U8 segmentation protocols like HLS/DASH, cache pre-warming can effectively resolve performance bottlenecks during the premiere phase. In traditional distribution models, users must fetch the M3U8 index file and associated TS segment resources from the origin station step by step during their first visit. If there is no cache on the edge nodes, it will lead to significant premiere delays and playback stuttering. The core principle of M3U8 pre-warming is to retrieve all TS segment resources associated with the M3U8 index file for pre-warming.
Core Value
Reduce Access Latency: User requests are directly obtained from the nearest EdgeOne node without returning to the origin station.
Increase Playback Success Rate: Reduce video interruptions caused by network fluctuations.
Optimize Origin Station Costs: Hot resources with high frequency can reduce bandwidth pressure on the origin station through EdgeOne's caching capability.
Steps
Example Scenario
Assuming you are a video vendor who has integrated the site domain
www.example.com
into EdgeOne acceleration and due to popular series updates, you expect that submitting the M3U8 resource of a film will automatically pre-warm the associated TS resources to EdgeOne.Step 1: Create a Pre-warming Task for M3U8
Note:
The M3U8 description file must be accessible and describe the segment paths according to industry standards. Supported formats are as follows:
Assuming the request URL is:
https://www.example.com/c8679239vodtranssgp1500031474/5fac87c91397757892217228202/adp.1505647.m3u8
.The content format of this URL is relative, such as 1505647_0_0.ts, and EdgeOne will concatenate it into the following TS URL:
https://www.example.com/c8679239vodtranssgp1500031474/5fac87c91397757892217228202/1505647_0_0.ts
.The recursive parsing depth of the M3U8 description file should not exceed 3 layers.
The parsed segment count will accumulate the daily pre-warming quota, and once it exceeds the quota, it will be handled silently without further warming.
1. The Targets field: the value is the URL of the M3U8, such as
https://www.example.com/c8679239vodtranssgp1500031474/5fac87c91397757892217228202/adp.1505647.m3u8
.2. The PrefetchMediaSegments field, value is on. The value explanation is:
on: Pre-warm the M3U8 description file while recursively parsing and pre-warming the TS resources described in the file.
off: If not filled, the default value is off. Only the submitted M3U8 description file will be pre-warmed.
3. Other parameter fields can be filled as needed.
Step 2: Query the Status of the M3U8 Pre-warming Task
Call the CreatePrefetchTask API, you can check based on the job-id returned when creating the pre-warming task or query through the target. The explanations of the task status are as follows:
processing: In progress.
success: Successful.
failed: Failed.
timeout: Timeout.
invalid: Invalid.
Calling Example
curl -X POST https://teo.tencentcloudapi.com -H "Authorization: TC3-HMAC-SHA256 Credential=******************************/2025-02-19/teo/tc3_request, SignedHeaders=content-type;host, Signature=9ec53d3ba8d4049c219052b0a2275ff3a30d3429d6295ae4c799c74d32c8f015" -H "Content-Type: application/json" -H "Host: teo.tencentcloudapi.com" -H "X-TC-Action: CreatePrefetchTask" -H "X-TC-Timestamp: 1739965395" -H "X-TC-Version: 2022-09-01" -H "X-TC-Language: zh-CN" -d '{"ZoneId":"zone-xxx","Targets":["https://www.example.com/c8679239vodtranssgp1500031474/5fac87c91397757892217228202/adp.1505647.m3u8"]}'
package mainimport ("fmt""github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common""github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors""github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"teo "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901")func main() {// Instantiate a credential object. You need to pass in the Tencent Cloud account's SecretId and SecretKey. Note the confidentiality of the keys.// Code leakage may result in the exposure of your SecretId and SecretKey, threatening the security of all resources under the account. The following code example is for reference only; it is recommended to use keys in a more secure manner. Please refer to: https://cloud.tencent.com/document/product/1278/85305// Keys can be obtained from the official console at https://console.cloud.tencent.com/cam/capicredential := common.NewCredential("SecretId","SecretKey",)// Instantiate a client option, optional, can be skipped if there are no special needscpf := profile.NewClientProfile()cpf.HttpProfile.Endpoint = "teo.tencentcloudapi.com"// Instantiate the client object for the requested product. For domestic sites, you can fill in ap-guangzhou as the access region; for international sites, fill in ap-singapore as the access region. clientProfile is optional. client, _ := teo.NewClient(credential, "ap-guangzhou", cpf)client, _ := teo.NewClient(credential, "ap-guangzhou", cpf)// Instantiate a request object; each interface corresponds to a request objectrequest := teo.NewCreatePrefetchTaskRequest()request.ZoneId = common.StringPtr("zone-364ni75dvzva")request.Targets = common.StringPtrs([]string{"https://www.example.com/1.m3u8"})request.PrefetchMediaSegments = common.StringPtr("on")// The returned resp is an instance of CreatePrefetchTaskResponse, corresponding to the request objectresponse, err := client.CreatePrefetchTask(request)if _, ok := err.(*errors.TencentCloudSDKError); ok {fmt.Printf("An API error has returned: %s", err)return}if err != nil {panic(err)}// Output JSON format string responsefmt.Printf("%s", response.ToJsonString())}