• 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
Docs/Cache Configuration/Cache Policy

Cache Policy

速盾网络 Team
Docs

Tags

  • Slow down��

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

Caching policies define advanced caching schemes that can be applied across the domain name. Policies combine multiple cache settings into a reusable configuration to facilitate unified management of cache behavior.

Understand caching strategies

A cache policy is a named configuration that specifies:

  • What content is cached
  • How long is it cached?
  • How to handle cache keys
  • Compression and optimization settings
code
缓存策略 "静态资源"
├── TTL:30天
├── 浏览器TTL:1天
├── 缓存键:URL + Accept-Encoding
├── 压缩:Brotli、Gzip
└── 提供陈旧内容:启用

Default policy

Sudun provides pre-configured policies for common use cases:

Standard policy

Balanced caching scheme for a typical website:

Set itemTake the value
Edge TTLFollow the origin header
Browser TTLFollow the origin header
cache keyURL + query string
CompressionAutomatic
Provide stale contentOnly when there is an error

Aggressive strategy

Maximizing caching schemes for static content:

Set itemTake the value
Edge TTL30 days
Browser TTL7 days
cache keyURL only
CompressionAlways enabled
Provide stale contentAlways enabled

Dynamic Strategy

Minimized caching schemes for dynamic content:

Set itemTake the value
Edge TTLNone
Browser TTLNone
cache keyNot applicable
CompressionReal-time compression
Provide stale contentNever

Create custom policies

Dashboard settings

  1. Go to Domains → and select your domain name
  2. Navigate to Cache → policies
  3. Click Create Policy
  4. Configure policy settings
  5. Click Save

Policy configuration

json
{
  "name": "我的静态策略",
  "description": "静态资源策略",
  "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:

Set itemDescriptionValue range
edge_ttlEdge node cache time0 - 31536000 (1 year)
browser_ttlBrowser cache time0 - 31536000
respect_originFollow the origin headertrue/false
min_ttlMinimum cache time0 - 86400
max_ttlMaximum cache time0 - 31536000

TTL Priority Rules:

code
若 respect_origin = true:
  TTL = 源站Cache-Control值(在min/max范围内)

若 respect_origin = false:
  TTL = edge_ttl设置值

Cache key settings

Define the unique identity of the cached content:

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:

optionsEffect
include_query_stringDifferentiate caches by query parameters
query_string_whitelistOnly these parameters affect the cache
query_string_blacklistIgnore these parameters
include_headersDifferentiate caches by request header
include_cookiesDifferentiate cache by cookie
include_device_typeDifferentiate between mobile/desktop caches
include_geoDifferentiate caches 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 mode:

modebehavior
autoAutomatically compress according to 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]
  }
}

Apply the policy

Apply to paths

Assign a policy to a specific path:

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

Apply to file types

Assignment Policies by File Extension:

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

Apply to content types

Assign policies by response content type:

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

Strategy inheritance

Policies can be inherited from other policies:

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

Inheritance Chain:

code
基础策略:aggressive-static
└── my-images-policy(继承并覆盖 browser_ttl)
    └── my-hero-images(继承并覆盖图像质量)

Policy versioning

Version control

Track changes in strategy 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": "将浏览器 TTL 增加到 7 天"
    },
    {
      "version": 2,
      "date": "2024-01-10",
      "changes": "添加了 Brotli 压缩"
    }
  ]
}

Rollback

Revert to a previous policy version:

  1. Go to Policies → to select a policy
  2. Click on Version History
  3. Select the version you want to restore
  4. Click Rollback

Strategy 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 strategy 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 Posts

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

API response

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 resources

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

Strategy analysis

View policy performance metrics:

IndicatorsDescription
Cache hit rateThe percentage of requests that serve from the cache
Origin uninstall rateOrigin request reduction percentage
Save bandwidthThe amount of data provided from the cache
Average TTLThe average time content spends in the cache

Dashboard metrics

  1. Go to Analyze → cache performance
  2. Filter by policy name
  3. View metrics over time

Troubleshooting

The policy is not in effect

  1. Check the policy assignment rules
  2. Verify path/extension match
  3. Check the policy priority order
  4. View the origin response header

Unexpected caching behavior

  1. Check if the origin response header overrides the policy
  2. Verify the cache key configuration
  3. Use curl tests to see the response header
  4. Check for conflicting rules

Low cache hit ratio

  1. Check the cache key settings (are they too specific?) )
  2. Check the TTL value (is it too short?) )
  3. Analyze query string variations
  4. Consider the device/geographic triage impact

API Reference

Create a 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 the 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 the strategy

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

Need help with caching policies? Please contact support@Sudun.com