Implementing Solutions with Mlytics API
Below are step-by-step instructions to configure prefetching and enable Range Requests using the Mlytics API.
Configuring Prefetching
Step 1: Identify Content to Prefetch
Determine the URLs of the files or directories that need to be prefetched to CDN edge nodes.
Step 2: Use the Prefetch API Endpoint
Make a POST request to the /prefetch
endpoint with the list of URLs.
API Endpoint:
POST /api/v1/prefetch
Headers:
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
Request Body:
{
"urls": [
"https://yourdomain.com/firmware/update1.bin",
"https://yourdomain.com/game/install.pkg"
]
}
Example using cURL:
curl -X POST https://api.mlytics.com/api/v1/prefetch \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"urls": [
"https://yourdomain.com/firmware/update1.bin",
"https://yourdomain.com/game/install.pkg"
]
}'
Step 3: Schedule Prefetching (Optional)
If you want to schedule the prefetch operation:
- Include a
scheduled_time
parameter in your request body in ISO 8601 format.
Example:
{
"urls": [
"https://yourdomain.com/firmware/update1.bin"
],
"scheduled_time": "2023-11-10T10:00:00Z"
}
Configuring Range Requests
Step 1: Access Your CDN Configuration
Use the Mlytics API to access and modify your CDN settings.
Step 2: Enable Range Request to Origin
Make a PUT request to the CDN configuration endpoint to enable Range Requests.
API Endpoint: See the following recipe for more instructions.
🦉
Set range request to origin server of domain
Open Recipe
curl -X PUT https://api.mlytics.com/api/v1/cdn/configuration \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"range_request_origin": true
}'
Step 3: Verify Configuration
Retrieve your CDN configuration to ensure that the range_request_origin
setting is enabled.
API Endpoint:
GET /api/v1/cdn/configuration
Example using cURL:
curl -X GET https://api.mlytics.com/api/v1/cdn/configuration \
-H "Authorization: Bearer YOUR_API_KEY"
Expected Response:
{
"range_request_origin": true,
"other_settings": "..."
}
GET /firmware/latest.bin HTTP/1.1
Host: download.example.com
Range: bytes=1000-2000
Updated 3 months ago
What’s Next