• Home
Home
Anti-DDoS CDNStatic & dynamic acceleration, edge scrubbingAnti-DDoS IP forwardingL4 forwarding with protected IPsSDK game shieldClient SDK for gaming workloadsAnti-DDoS serversDedicated compute with high availabilityLearn more
Gaming solutionLow latency + protectionFinancial solutionCompliance & scrubbingLive streaming solutionPush/pull at the edgeBlockchain solutionWeb3 infra protectionExplore
DocumentationAPIs & onboardingHelp centerFAQs & ticketsBlog & newsUpdates & best practicesGlobal speed testMulti-region performance checksTag cloudTopic map across the siteOpen docs
AboutMission & visionCareersHiringPartnersEcosystemContactSales & supportContact us

Documentation

  • Introduction
  • Best Practices
Docs/Cache Configuration/Cache Policy

Cache Policy

速盾网络 Team
Docs

Tags

  • 缓存

On this page

No outline

Share

𝕏fin

Enterprise CDN & acceleration with AI-driven monitoring and full-spectrum, real-time DDoS/CC protection. Trusted by tens of thousands of companies for fast, secure, and reliable content delivery and DDoS mitigation.

Product

  • Anti-DDoS CDN
  • Anti-DDoS IP forwarding
  • SDK game shield
  • Anti-DDoS servers

Solutions

  • Gaming solution
  • Financial solution
  • Live streaming solution
  • Blockchain solution

Resources

  • Documentation
  • Help center
  • Blog & news
  • Global speed test

Company

  • About
  • Careers
  • Partners
  • Contact

© 2026-2028 sudun.com 保留所有权利

  • Privacy
  • Terms
  • Cookies

Cache policies define high-level caching strategies that can be applied across your domain. Policies combine multiple cache settings into reusable configurations, making it easier to manage caching behavior consistently.

Understanding Cache Policies

A cache policy is a named configuration that specifies:

  • What content to cache
  • How long to cache it
  • How to handle cache keys
  • Compression and optimization settings
code
Cache Policy "Static Assets"
├── TTL: 30 days
├── Browser TTL: 1 day
├── Cache Key: URL + Accept-Encoding
├── Compression: Brotli, Gzip
└── Serve Stale: Enabled

Default Policies

Sudun includes pre-configured policies for common use cases:

Standard Policy

Balanced caching for typical websites:

SettingValue
Edge TTLRespect origin headers
Browser TTLRespect origin headers
Cache KeyURL + Query String
CompressionAuto
Serve StaleOn error only

Aggressive Policy

Maximum caching for static content:

SettingValue
Edge TTL30 days
Browser TTL7 days
Cache KeyURL only
CompressionAlways
Serve StaleAlways

Dynamic Policy

Minimal caching for dynamic content:

SettingValue
Edge TTLNone
Browser TTLNone
Cache KeyN/A
CompressionOn-the-fly
Serve StaleNever

Creating Custom Policies

Dashboard Setup

  1. Go to Domains → Select your domain
  2. Navigate to Caching → Policies
  3. Click Create Policy
  4. Configure policy settings
  5. Click Save

Policy Configuration

json
{
  "name": "my-static-policy",
  "description": "Policy for static assets",
  "settings": {
    "cache": {
      "edge_ttl": 2592000,
      "browser_ttl": 86400,
      "respect_origin": false
    },
    "cache_key": {
      "include_query_string": false,
      "include_headers": ["Accept-Encoding"]
    },
    "optimization": {
      "compression": "auto",
      "minify": false
    },
    "stale": {
      "serve_while_revalidate": true,
      "serve_on_error": true,
      "max_stale_age": 86400
    }
  }
}

Policy Settings

TTL Settings

Control cache duration:

SettingDescriptionRange
edge_ttlTime cached at edge0 - 31536000 (1 year)
browser_ttlTime cached in browser0 - 31536000
respect_originHonor origin headerstrue/false
min_ttlMinimum cache time0 - 86400
max_ttlMaximum cache time0 - 31536000

TTL Hierarchy:

code
If respect_origin = true:
  TTL = Origin Cache-Control (within min/max bounds)

If respect_origin = false:
  TTL = edge_ttl setting

Cache Key Settings

Define what makes cached content unique:

json
{
  "cache_key": {
    "include_query_string": true,
    "query_string_whitelist": ["page", "sort"],
    "query_string_blacklist": ["utm_*", "fbclid"],
    "include_headers": ["Accept-Encoding", "Accept-Language"],
    "include_cookies": [],
    "include_device_type": false,
    "include_geo": false
  }
}

Cache Key Options:

OptionEffect
include_query_stringVary cache by query parameters
query_string_whitelistOnly these params affect cache
query_string_blacklistIgnore these params
include_headersVary cache by request headers
include_cookiesVary cache by cookies
include_device_typeSeparate mobile/desktop cache
include_geoSeparate cache by country

Compression Settings

Configure content compression:

json
{
  "compression": {
    "mode": "auto",
    "algorithms": ["br", "gzip", "deflate"],
    "min_size": 1024,
    "types": ["text/*", "application/json", "application/javascript"]
  }
}

Compression Modes:

ModeBehavior
autoCompress based on content type and size
alwaysAlways compress eligible content
neverDisable compression
originUse origin compression only

Stale Content Settings

Configure stale content behavior:

json
{
  "stale": {
    "serve_while_revalidate": true,
    "serve_on_error": true,
    "max_stale_age": 86400,
    "error_codes": [500, 502, 503, 504]
  }
}

Applying Policies

Apply to Path

Assign a policy to specific paths:

json
{
  "policy_assignments": [
    {
      "policy": "aggressive-static",
      "match": {
        "path": "/static/*"
      }
    },
    {
      "policy": "dynamic",
      "match": {
        "path": "/api/*"
      }
    }
  ]
}

Apply to File Types

Assign policy by file extension:

json
{
  "policy": "aggressive-static",
  "match": {
    "file_extensions": ["css", "js", "jpg", "png", "woff2"]
  }
}

Apply to Content Type

Assign policy by response content type:

json
{
  "policy": "standard",
  "match": {
    "content_type": ["text/html", "application/xhtml+xml"]
  }
}

Policy Inheritance

Policies can inherit from other policies:

json
{
  "name": "my-images-policy",
  "inherits": "aggressive-static",
  "overrides": {
    "cache": {
      "browser_ttl": 604800
    },
    "optimization": {
      "image_optimization": true
    }
  }
}

Inheritance Chain:

code
Base Policy: aggressive-static
└── my-images-policy (inherits + overrides browser_ttl)
    └── my-hero-images (inherits + overrides image quality)

Policy Versioning

Version Control

Track policy changes over time:

json
{
  "name": "static-assets",
  "version": 3,
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-15T10:30:00Z",
  "changelog": [
    {
      "version": 3,
      "date": "2024-01-15",
      "changes": "Increased browser TTL to 7 days"
    },
    {
      "version": 2,
      "date": "2024-01-10",
      "changes": "Added Brotli compression"
    }
  ]
}

Rollback

Revert to a previous policy version:

  1. Go to Policies → Select policy
  2. Click Version History
  3. Select the version to restore
  4. Click Rollback

Policy Testing

Preview Mode

Test policy changes before deployment:

json
{
  "preview": true,
  "test_urls": [
    "https://example.com/test-page",
    "https://example.com/static/test.css"
  ]
}

A/B Testing

Test policy effectiveness:

json
{
  "ab_test": {
    "enabled": true,
    "variants": [
      {
        "name": "control",
        "policy": "current-policy",
        "weight": 50
      },
      {
        "name": "experiment",
        "policy": "new-policy",
        "weight": 50
      }
    ],
    "metrics": ["cache_hit_ratio", "origin_requests", "ttfb"]
  }
}

Common Policy Patterns

E-commerce Product Pages

json
{
  "name": "product-pages",
  "settings": {
    "cache": {
      "edge_ttl": 3600,
      "browser_ttl": 300
    },
    "cache_key": {
      "include_query_string": true,
      "query_string_whitelist": ["variant", "color", "size"]
    },
    "stale": {
      "serve_while_revalidate": true,
      "max_stale_age": 3600
    }
  }
}

News/Blog Articles

json
{
  "name": "blog-content",
  "settings": {
    "cache": {
      "edge_ttl": 600,
      "browser_ttl": 60
    },
    "stale": {
      "serve_while_revalidate": true,
      "serve_on_error": true
    }
  }
}

API Responses

json
{
  "name": "api-cacheable",
  "settings": {
    "cache": {
      "edge_ttl": 60,
      "browser_ttl": 0,
      "respect_origin": true
    },
    "cache_key": {
      "include_query_string": true,
      "include_headers": ["Authorization"]
    }
  }
}

Versioned Assets

json
{
  "name": "immutable-assets",
  "settings": {
    "cache": {
      "edge_ttl": 31536000,
      "browser_ttl": 31536000,
      "immutable": true
    },
    "cache_key": {
      "include_query_string": false
    }
  }
}

Policy Analytics

View policy performance metrics:

MetricDescription
Cache Hit Ratio% of requests served from cache
Origin Offload% reduction in origin requests
Bandwidth SavedData served from cache
Avg TTLAverage time content stays cached

Dashboard Metrics

  1. Go to Analytics → Cache Performance
  2. Filter by policy name
  3. View metrics over time

Troubleshooting

Policy Not Applying

  1. Check policy assignment rules
  2. Verify path/extension matching
  3. Check policy priority order
  4. Review origin response headers

Unexpected Cache Behavior

  1. Check if origin headers override policy
  2. Verify cache key configuration
  3. Test with curl to see response headers
  4. Check for conflicting rules

Low Cache Hit Ratio

  1. Review cache key settings (too specific?)
  2. Check TTL values (too short?)
  3. Analyze query string variations
  4. Consider device/geo splitting impact

API Reference

Create Policy

bash
curl -X POST https://api.Sudun.com/v1/domains/example.com/policies \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-policy",
    "settings": {
      "cache": {"edge_ttl": 86400},
      "compression": {"mode": "auto"}
    }
  }'

Update Policy

bash
curl -X PUT https://api.Sudun.com/v1/domains/example.com/policies/my-policy \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "settings": {
      "cache": {"edge_ttl": 172800}
    }
  }'

List Policies

bash
curl -X GET https://api.Sudun.com/v1/domains/example.com/policies \
  -H "Authorization: Bearer YOUR_API_KEY"

Need help with cache policies? Contact support@Sudun.com