Content prefetching proactively loads content into edge caches before users request it. This ensures cache hits from the first request, eliminating cold-start latency and improving user experience.
Traditional Flow:
User Request → Cache MISS → Origin Fetch → Cache Store → Response
Prefetch Flow:
Prefetch Job → Origin Fetch → Cache Store (ready)
User Request → Cache HIT → Immediate Response
| Benefit | Description |
|---|---|
| Eliminate cold starts | First visitors get cached content |
| Faster page loads | No origin round-trip delay |
| Predictable performance | Consistent response times |
| Origin protection | Spread load over time |
Prefetch specific URLs:
{
"urls": [
"https://example.com/",
"https://example.com/products",
"https://example.com/about",
"https://example.com/css/styles.css",
"https://example.com/js/app.js"
]
}
Best for: Known critical pages, landing pages, marketing campaigns
Automatically prefetch URLs from your sitemap:
Sitemap URL: https://example.com/sitemap.xml
Sudun parses your sitemap and prefetches all listed URLs:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/page1</loc>
<lastmod>2024-01-15</lastmod>
</url>
<url>
<loc>https://example.com/page2</loc>
</url>
</urlset>
Best for: Full site warming, SEO-critical pages
Automatically discover and prefetch linked content:
{
"start_url": "https://example.com/",
"depth": 2,
"max_urls": 100
}
The crawler follows links to discover content:
Depth 0: Homepage
Depth 1: Pages linked from homepage
Depth 2: Pages linked from depth 1 pages
Best for: Dynamic sites, discovering new content
- Source: URL List, Sitemap, or Crawl
- Schedule: One-time or recurring
- Options: Headers, regions, concurrency
| Option | Description | Default |
|---|---|---|
| Regions | PoPs to prefetch into | All regions |
| Concurrency | Parallel requests to origin | 5 |
| Headers | Custom headers for prefetch requests | None |
| Ignore Robots | Skip robots.txt restrictions | No |
Prefetch to specific geographic regions:
{
"urls": ["https://example.com/"],
"regions": ["us-east", "eu-west", "asia-pacific"]
}
Available Regions:
| Region ID | Location |
|---|---|
| us-east | North America East |
| us-west | North America West |
| eu-west | Europe West |
| eu-central | Europe Central |
| asia-pacific | Asia Pacific |
| asia-south | South Asia |
Run prefetch immediately or at a scheduled time:
{
"schedule": {
"type": "once",
"run_at": "2024-01-15T06:00:00Z"
}
}
Set up automatic recurring prefetch:
{
"schedule": {
"type": "recurring",
"interval": "daily",
"time": "04:00",
"timezone": "UTC"
}
}
Schedule Options:
| Interval | Description | Use Case |
|---|---|---|
| hourly | Every hour | Frequently updated content |
| daily | Once per day | Standard websites |
| weekly | Once per week | Static content |
| custom | Cron expression | Complex schedules |
For advanced scheduling:
{
"schedule": {
"type": "cron",
"expression": "0 */6 * * *"
}
}
Common patterns:
0 4 * * * - Daily at 4 AM0 */2 * * * - Every 2 hours0 0 * * 0 - Weekly on SundaySend specific headers during prefetch:
{
"headers": {
"Accept-Language": "en-US",
"Accept-Encoding": "gzip, br",
"X-Prefetch": "true"
}
}
Configure the prefetch user agent:
{
"user_agent": "Sudun-Prefetch/1.0"
}
Tip: Your origin can detect prefetch requests via the User-Agent or custom header and log them separately.
Automatically prefetch after deployment:
# CI/CD integration
- name: Deploy
run: deploy-script.sh
- name: Warm Cache
run: |
curl -X POST https://api.Sudun.com/v1/domains/example.com/prefetch \
-H "Authorization: Bearer $API_KEY" \
-d '{"sitemap": "https://example.com/sitemap.xml"}'
Trigger prefetch via webhook:
curl -X POST https://api.Sudun.com/v1/domains/example.com/prefetch/trigger \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"job_id": "prefetch-job-123"}'
Prefetch when content changes:
{
"trigger": {
"type": "purge",
"action": "prefetch_after_purge"
}
}
Track prefetch job progress:
| Status | Description |
|---|---|
| Pending | Job queued |
| Running | Prefetch in progress |
| Completed | All URLs prefetched |
| Failed | Job failed (see errors) |
| Partial | Some URLs failed |
View metrics in the dashboard:
{
"job_id": "pf-abc123",
"status": "completed",
"started_at": "2024-01-15T04:00:00Z",
"completed_at": "2024-01-15T04:05:32Z",
"stats": {
"total_urls": 150,
"successful": 148,
"failed": 2,
"skipped": 0
}
}
Prefetch most important pages first:
{
"urls": [
{"url": "https://example.com/", "priority": "high"},
{"url": "https://example.com/products", "priority": "high"},
{"url": "https://example.com/blog", "priority": "medium"},
{"url": "https://example.com/about", "priority": "low"}
]
}
Configure concurrency to avoid overloading origin:
{
"concurrency": 3,
"rate_limit": "10/second"
}
Run prefetch when traffic is lowest:
Peak Hours: 9 AM - 6 PM
Prefetch Window: 2 AM - 5 AM
Skip URLs that shouldn't be prefetched:
{
"exclude_patterns": [
"/api/*",
"/admin/*",
"*.json",
"*?session=*"
]
}
If prefetch overloads your origin:
If content isn't cached after prefetch:
curl -X POST https://api.Sudun.com/v1/domains/example.com/prefetch \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"urls": [
"https://example.com/",
"https://example.com/products"
],
"regions": ["us-east", "eu-west"],
"concurrency": 5
}'
curl -X POST https://api.Sudun.com/v1/domains/example.com/prefetch \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"sitemap": "https://example.com/sitemap.xml",
"schedule": {
"type": "daily",
"time": "04:00"
}
}'
curl -X GET https://api.Sudun.com/v1/domains/example.com/prefetch/job-123 \
-H "Authorization: Bearer YOUR_API_KEY"
Need help with content prefetching? Contact support@Sudun.com