[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6NYMCCKPRJFEQ3Z73V3DKDP":3,"skill-same:01M6NYMCCKPRJFEQ3Z73V3DKDP":71},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":29,"commitSha":52,"skillDirectory":53,"forksCount":13,"repositoryHtmlUrl":54,"repositoryHomepageUrl":6,"ownerHtmlUrl":55,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":56,"install":57,"resources":70},"01M6NYMCCKPRJFEQ3Z73V3DKDP","cdn-setup",null,"Configure CDNs for content delivery. Set up CloudFront, Cloudflare, and Fastly. Use when optimizing global content delivery.","duc-duy-1612\u002FOnline-Delivery-Systems-Web","duc-duy-1612","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F192231384?v=4","01M6NSDKQQDKVTHZ8DZMZ1VYY6","01M6NSDKW8DDVTQHBT1HBDDJPT",0,"MIT","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fcdn-setup\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"setup","cdn","cdn setup","fastly","security","relevant","cloudfront","scripts","critical","os","delivery","main","community","up","only","configure","access","devops-security","SET","cloudflare","2026-11-10 10:12:30",false,"---\nname: cdn-setup\ndescription: Configure CDNs for content delivery. Set up CloudFront, Cloudflare, and\n  Fastly. Use when optimizing global content delivery.\ncategory: devops\nrisk: critical\nsource: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\nsource_repo: BagelHole\u002FDevOps-Security-Agent-Skills\nsource_type: community\ndate_added: '2026-09-20'\nlicense: MIT\nlicense_source: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE\ncompatibility: Requires the relevant OS\u002Fplatform tooling and privileged access where\n  noted. Docs-only; helper scripts and templates not bundled.\nmetadata:\n  author: devops-skills\n  version: '1.0'\n---\n\n# CDN Setup\n\nConfigure content delivery networks for fast, reliable global asset delivery with proper caching, invalidation, and security.\n\n## When to Use\n\n- Serving static assets (JS, CSS, images, fonts) globally with low latency.\n- Offloading traffic from origin servers to reduce compute costs.\n- Adding TLS termination and DDoS protection at the edge.\n- Implementing geo-based routing or content restrictions.\n- Accelerating API responses with edge caching.\n\n## Prerequisites\n\n- Domain with DNS management access.\n- Origin server or S3\u002FR2 bucket with content to serve.\n- AWS CLI configured (for CloudFront).\n- Cloudflare account with zone configured (for Cloudflare CDN).\n- Terraform 1.5+ (for infrastructure-as-code examples).\n\n## AWS CloudFront\n\n### Create a Distribution via CLI\n\n```bash\n# Create an S3 origin distribution with OAC (Origin Access Control)\naws cloudfront create-distribution --distribution-config '{\n  \"CallerReference\": \"my-site-'$(date +%s)'\",\n  \"Comment\": \"Production site CDN\",\n  \"Enabled\": true,\n  \"Origins\": {\n    \"Quantity\": 1,\n    \"Items\": [{\n      \"Id\": \"s3-origin\",\n      \"DomainName\": \"my-bucket.s3.us-east-1.amazonaws.com\",\n      \"OriginPath\": \"\",\n      \"S3OriginConfig\": {\n        \"OriginAccessIdentity\": \"\"\n      },\n      \"OriginAccessControlId\": \"E2QWRUHAPOMQZL\"\n    }]\n  },\n  \"DefaultCacheBehavior\": {\n    \"TargetOriginId\": \"s3-origin\",\n    \"ViewerProtocolPolicy\": \"redirect-to-https\",\n    \"AllowedMethods\": {\n      \"Quantity\": 2,\n      \"Items\": [\"GET\", \"HEAD\"]\n    },\n    \"CachePolicyId\": \"658327ea-f89d-4fab-a63d-7e88639e58f6\",\n    \"Compress\": true\n  },\n  \"DefaultRootObject\": \"index.html\",\n  \"PriceClass\": \"PriceClass_100\",\n  \"ViewerCertificate\": {\n    \"ACMCertificateArn\": \"arn:aws:acm:us-east-1:123456789:certificate\u002Fabc-123\",\n    \"SSLSupportMethod\": \"sni-only\",\n    \"MinimumProtocolVersion\": \"TLSv1.2_2021\"\n  },\n  \"Aliases\": {\n    \"Quantity\": 1,\n    \"Items\": [\"www.example.com\"]\n  },\n  \"CustomErrorResponses\": {\n    \"Quantity\": 1,\n    \"Items\": [{\n      \"ErrorCode\": 404,\n      \"ResponseCode\": \"200\",\n      \"ResponsePagePath\": \"\u002Findex.html\",\n      \"ErrorCachingMinTTL\": 10\n    }]\n  }\n}'\n```\n\n### Cache Invalidation\n\n```bash\n# Invalidate specific paths\naws cloudfront create-invalidation \\\n  --distribution-id E1A2B3C4D5E6F7 \\\n  --paths \"\u002Findex.html\" \"\u002Fcss\u002F*\" \"\u002Fjs\u002F*\"\n\n# Invalidate everything (costs apply per path)\naws cloudfront create-invalidation \\\n  --distribution-id E1A2B3C4D5E6F7 \\\n  --paths \"\u002F*\"\n\n# Check invalidation status\naws cloudfront get-invalidation \\\n  --distribution-id E1A2B3C4D5E6F7 \\\n  --id I1A2B3C4D5E6F7\n\n# List recent invalidations\naws cloudfront list-invalidations --distribution-id E1A2B3C4D5E6F7\n```\n\n### CloudFront Functions (Lightweight Edge Logic)\n\n```javascript\n\u002F\u002F URL rewrite function — add index.html to directory requests\nfunction handler(event) {\n  var request = event.request;\n  var uri = request.uri;\n\n  if (uri.endsWith('\u002F')) {\n    request.uri += 'index.html';\n  } else if (!uri.includes('.')) {\n    request.uri += '\u002Findex.html';\n  }\n\n  return request;\n}\n```\n\n### CloudFront with Terraform\n\n```hcl\n# cloudfront.tf\nresource \"aws_cloudfront_distribution\" \"site\" {\n  enabled             = true\n  is_ipv6_enabled     = true\n  default_root_object = \"index.html\"\n  aliases             = [\"www.example.com\"]\n  price_class         = \"PriceClass_100\"\n\n  origin {\n    domain_name              = aws_s3_bucket.site.bucket_regional_domain_name\n    origin_id                = \"s3-origin\"\n    origin_access_control_id = aws_cloudfront_origin_access_control.oac.id\n  }\n\n  default_cache_behavior {\n    allowed_methods  = [\"GET\", \"HEAD\"]\n    cached_methods   = [\"GET\", \"HEAD\"]\n    target_origin_id = \"s3-origin\"\n\n    cache_policy_id          = \"658327ea-f89d-4fab-a63d-7e88639e58f6\" # CachingOptimized\n    origin_request_policy_id = \"88a5eaf4-2fd4-4709-b370-b4c650ea3fcf\" # CORS-S3Origin\n\n    viewer_protocol_policy = \"redirect-to-https\"\n    compress               = true\n  }\n\n  # SPA fallback\n  custom_error_response {\n    error_code         = 404\n    response_code      = 200\n    response_page_path = \"\u002Findex.html\"\n  }\n\n  # API pass-through (no caching)\n  ordered_cache_behavior {\n    path_pattern     = \"\u002Fapi\u002F*\"\n    allowed_methods  = [\"GET\", \"HEAD\", \"OPTIONS\", \"PUT\", \"POST\", \"PATCH\", \"DELETE\"]\n    cached_methods   = [\"GET\", \"HEAD\"]\n    target_origin_id = \"api-origin\"\n\n    cache_policy_id          = \"4135ea2d-6df8-44a3-9df3-4b5a84be39ad\" # CachingDisabled\n    origin_request_policy_id = \"b689b0a8-53d0-40ab-baf2-68738e2966ac\" # AllViewerExceptHostHeader\n\n    viewer_protocol_policy = \"https-only\"\n  }\n\n  viewer_certificate {\n    acm_certificate_arn      = aws_acm_certificate.cert.arn\n    ssl_support_method       = \"sni-only\"\n    minimum_protocol_version = \"TLSv1.2_2021\"\n  }\n\n  restrictions {\n    geo_restriction {\n      restriction_type = \"none\"\n    }\n  }\n}\n\nresource \"aws_cloudfront_origin_access_control\" \"oac\" {\n  name                              = \"s3-oac\"\n  origin_access_control_origin_type = \"s3\"\n  signing_behavior                  = \"always\"\n  signing_protocol                  = \"sigv4\"\n}\n```\n\n## Cloudflare CDN\n\n### Zone Setup\n\n```bash\n# Add a zone\ncurl -X POST \"https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones\" \\\n  -H \"Authorization: Bearer $CF_API_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"name\":\"example.com\",\"jump_start\":true}'\n\n# Get zone ID\nZONE_ID=$(curl -s \"https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones?name=example.com\" \\\n  -H \"Authorization: Bearer $CF_API_TOKEN\" | jq -r '.result[0].id')\n```\n\n### Cache Rules (Replacing Page Rules)\n\n```bash\n# Create a cache rule for static assets\ncurl -X POST \"https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones\u002F$ZONE_ID\u002Frulesets\u002Fphases\u002Fhttp_request_cache_settings\u002Fentrypoint\" \\\n  -H \"Authorization: Bearer $CF_API_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"rules\": [\n      {\n        \"expression\": \"(http.request.uri.path.extension in {\\\"css\\\" \\\"js\\\" \\\"png\\\" \\\"jpg\\\" \\\"woff2\\\" \\\"svg\\\"})\",\n        \"action\": \"set_cache_settings\",\n        \"action_parameters\": {\n          \"cache\": true,\n          \"browser_ttl\": { \"mode\": \"override_origin\", \"default\": 2592000 },\n          \"edge_ttl\": { \"mode\": \"override_origin\", \"default\": 86400 }\n        },\n        \"description\": \"Cache static assets aggressively\"\n      }\n    ]\n  }'\n```\n\n### Purge Cache\n\n```bash\n# Purge everything\ncurl -X POST \"https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones\u002F$ZONE_ID\u002Fpurge_cache\" \\\n  -H \"Authorization: Bearer $CF_API_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"purge_everything\":true}'\n\n# Purge specific URLs\ncurl -X POST \"https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones\u002F$ZONE_ID\u002Fpurge_cache\" \\\n  -H \"Authorization: Bearer $CF_API_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"files\":[\"https:\u002F\u002Fexample.com\u002Fstyle.css\",\"https:\u002F\u002Fexample.com\u002Fapp.js\"]}'\n\n# Purge by prefix\ncurl -X POST \"https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones\u002F$ZONE_ID\u002Fpurge_cache\" \\\n  -H \"Authorization: Bearer $CF_API_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"prefixes\":[\"https:\u002F\u002Fexample.com\u002Fimages\u002F\"]}'\n```\n\n## Cache Headers on Origin\n\n### nginx Cache Headers\n\n```nginx\n# Immutable hashed assets (fingerprinted filenames)\nlocation ~* \\.(js|css)$ {\n    if ($uri ~* \"\\.[a-f0-9]{8,}\\.(js|css)$\") {\n        expires 1y;\n        add_header Cache-Control \"public, immutable\";\n    }\n    expires 7d;\n    add_header Cache-Control \"public, must-revalidate\";\n}\n\n# Images and fonts\nlocation ~* \\.(jpg|jpeg|png|gif|ico|svg|webp|woff2|ttf)$ {\n    expires 30d;\n    add_header Cache-Control \"public, immutable\";\n}\n\n# HTML — always revalidate\nlocation ~* \\.html$ {\n    expires -1;\n    add_header Cache-Control \"no-cache, must-revalidate\";\n}\n\n# API responses — no caching\nlocation \u002Fapi\u002F {\n    add_header Cache-Control \"no-store, no-cache\";\n    add_header Vary \"Authorization, Accept\";\n}\n```\n\n### Cache-Control Cheat Sheet\n\n| Header | Meaning |\n|--------|---------|\n| `public, max-age=31536000, immutable` | Cache for 1 year, never revalidate (hashed assets) |\n| `public, max-age=86400, must-revalidate` | Cache 1 day, check freshness after |\n| `private, max-age=600` | Browser cache only, 10 min (user-specific content) |\n| `no-cache` | Always revalidate with origin before serving |\n| `no-store` | Never cache (sensitive data) |\n| `s-maxage=3600` | CDN caches for 1 hour, overrides `max-age` for shared caches |\n\n## Cache Warming\n\n```bash\n# Warm cache for critical pages after deployment\n#!\u002Fbin\u002Fbash\nURLS=(\n  \"https:\u002F\u002Fwww.example.com\u002F\"\n  \"https:\u002F\u002Fwww.example.com\u002Fproducts\"\n  \"https:\u002F\u002Fwww.example.com\u002Fabout\"\n  \"https:\u002F\u002Fwww.example.com\u002Fcss\u002Fmain.abc123.css\"\n  \"https:\u002F\u002Fwww.example.com\u002Fjs\u002Fapp.def456.js\"\n)\n\nfor url in \"${URLS[@]}\"; do\n  curl -s -o \u002Fdev\u002Fnull -w \"%{http_code} %{time_total}s %{url_effective}\\n\" \"$url\"\ndone\n```\n\n## Monitoring Cache Performance\n\n```bash\n# Check cache status from response headers\ncurl -sI https:\u002F\u002Fwww.example.com\u002Fstyle.css | grep -i -E \"cf-cache|x-cache|age|cache-control\"\n\n# Expected headers:\n# cf-cache-status: HIT (Cloudflare)\n# x-cache: Hit from cloudfront (CloudFront)\n# age: 3600 (seconds since cached)\n\n# CloudFront cache hit ratio\naws cloudwatch get-metric-statistics \\\n  --namespace AWS\u002FCloudFront \\\n  --metric-name CacheHitRate \\\n  --dimensions Name=DistributionId,Value=E1A2B3C4D5E6F7 \\\n  --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S) \\\n  --end-time $(date -u +%Y-%m-%dT%H:%M:%S) \\\n  --period 300 \\\n  --statistics Average\n```\n\n## Troubleshooting\n\n| Symptom | Cause | Fix |\n|---------|-------|-----|\n| `cf-cache-status: DYNAMIC` | No cache rule matches or Cache-Control prevents it | Set `s-maxage` or create a cache rule for the path |\n| Cache hit ratio below 50% | Low TTLs or high URL cardinality (query strings) | Increase TTL; strip unnecessary query strings in cache key |\n| Stale content after deploy | Old objects still cached at edge | Invalidate; use content-hashed filenames to avoid this entirely |\n| CORS errors through CDN | CDN strips or caches wrong `Vary` header | Add `Vary: Origin` and configure origin request policy to forward `Origin` |\n| 502 errors from CDN | Origin down or timeout | Check origin health; increase CDN origin timeout settings |\n| Mixed content warnings | CDN serves HTTPS but origin links use HTTP | Set `viewer-protocol-policy: redirect-to-https`; fix origin URLs |\n| High invalidation costs | Purging `\u002F*` on every deploy | Use fingerprinted filenames; only invalidate `index.html` |\n\n## Related Skills\n\n- dns-management (`dns-management`) - DNS records for CDN CNAME setup\n- cloudflare-pages (`cloudflare-pages`) - Cloudflare's built-in CDN for Pages projects\n- reverse-proxy (`reverse-proxy`) - Origin server configuration behind CDN\n- load-balancing (`load-balancing`) - Multi-origin CDN backends\n\n## Limitations\n\n- Infrastructure commands can disrupt services: confirm target host\u002Fscope and have backups\u002Fsnapshots before mutating state.\n- Docs-only import: upstream scripts and templates not bundled.\n\n","# CDN Setup\n\nConfigure content delivery networks for fast, reliable global asset delivery with proper caching, invalidation, and security.\n\n## When to Use\n\n- Serving static assets (JS, CSS, images, fonts) globally with low latency.\n- Offloading traffic from origin servers to reduce compute costs.\n- Adding TLS termination and DDoS protection at the edge.\n- Implementing geo-based routing or content restrictions.\n- Accelerating API responses with edge caching.\n\n## Prerequisites\n\n- Domain with DNS management access.\n- Origin server or S3\u002FR2 bucket with content to serve.\n- AWS CLI configured (for CloudFront).\n- Cloudflare account with zone configured (for Cloudflare CDN).\n- Terraform 1.5+ (for infrastructure-as-code examples).\n\n## AWS CloudFront\n\n### Create a Distribution via CLI\n\n```bash\n# Create an S3 origin distribution with OAC (Origin Access Control)\naws cloudfront create-distribution --distribution-config '{\n  \"CallerReference\": \"my-site-'$(date +%s)'\",\n  \"Comment\": \"Production site CDN\",\n  \"Enabled\": true,\n  \"Origins\": {\n    \"Quantity\": 1,\n    \"Items\": [{\n      \"Id\": \"s3-origin\",\n      \"DomainName\": \"my-bucket.s3.us-east-1.amazonaws.com\",\n      \"OriginPath\": \"\",\n      \"S3OriginConfig\": {\n        \"OriginAccessIdentity\": \"\"\n      },\n      \"OriginAccessControlId\": \"E2QWRUHAPOMQZL\"\n    }]\n  },\n  \"DefaultCacheBehavior\": {\n    \"TargetOriginId\": \"s3-origin\",\n    \"ViewerProtocolPolicy\": \"redirect-to-https\",\n    \"AllowedMethods\": {\n      \"Quantity\": 2,\n      \"Items\": [\"GET\", \"HEAD\"]\n    },\n    \"CachePolicyId\": \"658327ea-f89d-4fab-a63d-7e88639e58f6\",\n    \"Compress\": true\n  },\n  \"DefaultRootObject\": \"index.html\",\n  \"PriceClass\": \"PriceClass_100\",\n  \"ViewerCertificate\": {\n    \"ACMCertificateArn\": \"arn:aws:acm:us-east-1:123456789:certificate\u002Fabc-123\",\n    \"SSLSupportMethod\": \"sni-only\",\n    \"MinimumProtocolVersion\": \"TLSv1.2_2021\"\n  },\n  \"Aliases\": {\n    \"Quantity\": 1,\n    \"Items\": [\"www.example.com\"]\n  },\n  \"CustomErrorResponses\": {\n    \"Quantity\": 1,\n    \"Items\": [{\n      \"ErrorCode\": 404,\n      \"ResponseCode\": \"200\",\n      \"ResponsePagePath\": \"\u002Findex.html\",\n      \"ErrorCachingMinTTL\": 10\n    }]\n  }\n}'\n```\n\n### Cache Invalidation\n\n```bash\n# Invalidate specific paths\naws cloudfront create-invalidation \\\n  --distribution-id E1A2B3C4D5E6F7 \\\n  --paths \"\u002Findex.html\" \"\u002Fcss\u002F*\" \"\u002Fjs\u002F*\"\n\n# Invalidate everything (costs apply per path)\naws cloudfront create-invalidation \\\n  --distribution-id E1A2B3C4D5E6F7 \\\n  --paths \"\u002F*\"\n\n# Check invalidation status\naws cloudfront get-invalidation \\\n  --distribution-id E1A2B3C4D5E6F7 \\\n  --id I1A2B3C4D5E6F7\n\n# List recent invalidations\naws cloudfront list-invalidations --distribution-id E1A2B3C4D5E6F7\n```\n\n### CloudFront Functions (Lightweight Edge Logic)\n\n```javascript\n\u002F\u002F URL rewrite function — add index.html to directory requests\nfunction handler(event) {\n  var request = event.request;\n  var uri = request.uri;\n\n  if (uri.endsWith('\u002F')) {\n    request.uri += 'index.html';\n  } else if (!uri.includes('.')) {\n    request.uri += '\u002Findex.html';\n  }\n\n  return request;\n}\n```\n\n### CloudFront with Terraform\n\n```hcl\n# cloudfront.tf\nresource \"aws_cloudfront_distribution\" \"site\" {\n  enabled             = true\n  is_ipv6_enabled     = true\n  default_root_object = \"index.html\"\n  aliases             = [\"www.example.com\"]\n  price_class         = \"PriceClass_100\"\n\n  origin {\n    domain_name              = aws_s3_bucket.site.bucket_regional_domain_name\n    origin_id                = \"s3-origin\"\n    origin_access_control_id = aws_cloudfront_origin_access_control.oac.id\n  }\n\n  default_cache_behavior {\n    allowed_methods  = [\"GET\", \"HEAD\"]\n    cached_methods   = [\"GET\", \"HEAD\"]\n    target_origin_id = \"s3-origin\"\n\n    cache_policy_id          = \"658327ea-f89d-4fab-a63d-7e88639e58f6\" # CachingOptimized\n    origin_request_policy_id = \"88a5eaf4-2fd4-4709-b370-b4c650ea3fcf\" # CORS-S3Origin\n\n    viewer_protocol_policy = \"redirect-to-https\"\n    compress               = true\n  }\n\n  # SPA fallback\n  custom_error_response {\n    error_code         = 404\n    response_code      = 200\n    response_page_path = \"\u002Findex.html\"\n  }\n\n  # API pass-through (no caching)\n  ordered_cache_behavior {\n    path_pattern     = \"\u002Fapi\u002F*\"\n    allowed_methods  = [\"GET\", \"HEAD\", \"OPTIONS\", \"PUT\", \"POST\", \"PATCH\", \"DELETE\"]\n    cached_methods   = [\"GET\", \"HEAD\"]\n    target_origin_id = \"api-origin\"\n\n    cache_policy_id          = \"4135ea2d-6df8-44a3-9df3-4b5a84be39ad\" # CachingDisabled\n    origin_request_policy_id = \"b689b0a8-53d0-40ab-baf2-68738e2966ac\" # AllViewerExceptHostHeader\n\n    viewer_protocol_policy = \"https-only\"\n  }\n\n  viewer_certificate {\n    acm_certificate_arn      = aws_acm_certificate.cert.arn\n    ssl_support_method       = \"sni-only\"\n    minimum_protocol_version = \"TLSv1.2_2021\"\n  }\n\n  restrictions {\n    geo_restriction {\n      restriction_type = \"none\"\n    }\n  }\n}\n\nresource \"aws_cloudfront_origin_access_control\" \"oac\" {\n  name                              = \"s3-oac\"\n  origin_access_control_origin_type = \"s3\"\n  signing_behavior                  = \"always\"\n  signing_protocol                  = \"sigv4\"\n}\n```\n\n## Cloudflare CDN\n\n### Zone Setup\n\n```bash\n# Add a zone\ncurl -X POST \"https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones\" \\\n  -H \"Authorization: Bearer $CF_API_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"name\":\"example.com\",\"jump_start\":true}'\n\n# Get zone ID\nZONE_ID=$(curl -s \"https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones?name=example.com\" \\\n  -H \"Authorization: Bearer $CF_API_TOKEN\" | jq -r '.result[0].id')\n```\n\n### Cache Rules (Replacing Page Rules)\n\n```bash\n# Create a cache rule for static assets\ncurl -X POST \"https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones\u002F$ZONE_ID\u002Frulesets\u002Fphases\u002Fhttp_request_cache_settings\u002Fentrypoint\" \\\n  -H \"Authorization: Bearer $CF_API_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"rules\": [\n      {\n        \"expression\": \"(http.request.uri.path.extension in {\\\"css\\\" \\\"js\\\" \\\"png\\\" \\\"jpg\\\" \\\"woff2\\\" \\\"svg\\\"})\",\n        \"action\": \"set_cache_settings\",\n        \"action_parameters\": {\n          \"cache\": true,\n          \"browser_ttl\": { \"mode\": \"override_origin\", \"default\": 2592000 },\n          \"edge_ttl\": { \"mode\": \"override_origin\", \"default\": 86400 }\n        },\n        \"description\": \"Cache static assets aggressively\"\n      }\n    ]\n  }'\n```\n\n### Purge Cache\n\n```bash\n# Purge everything\ncurl -X POST \"https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones\u002F$ZONE_ID\u002Fpurge_cache\" \\\n  -H \"Authorization: Bearer $CF_API_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"purge_everything\":true}'\n\n# Purge specific URLs\ncurl -X POST \"https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones\u002F$ZONE_ID\u002Fpurge_cache\" \\\n  -H \"Authorization: Bearer $CF_API_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"files\":[\"https:\u002F\u002Fexample.com\u002Fstyle.css\",\"https:\u002F\u002Fexample.com\u002Fapp.js\"]}'\n\n# Purge by prefix\ncurl -X POST \"https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones\u002F$ZONE_ID\u002Fpurge_cache\" \\\n  -H \"Authorization: Bearer $CF_API_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"prefixes\":[\"https:\u002F\u002Fexample.com\u002Fimages\u002F\"]}'\n```\n\n## Cache Headers on Origin\n\n### nginx Cache Headers\n\n```nginx\n# Immutable hashed assets (fingerprinted filenames)\nlocation ~* \\.(js|css)$ {\n    if ($uri ~* \"\\.[a-f0-9]{8,}\\.(js|css)$\") {\n        expires 1y;\n        add_header Cache-Control \"public, immutable\";\n    }\n    expires 7d;\n    add_header Cache-Control \"public, must-revalidate\";\n}\n\n# Images and fonts\nlocation ~* \\.(jpg|jpeg|png|gif|ico|svg|webp|woff2|ttf)$ {\n    expires 30d;\n    add_header Cache-Control \"public, immutable\";\n}\n\n# HTML — always revalidate\nlocation ~* \\.html$ {\n    expires -1;\n    add_header Cache-Control \"no-cache, must-revalidate\";\n}\n\n# API responses — no caching\nlocation \u002Fapi\u002F {\n    add_header Cache-Control \"no-store, no-cache\";\n    add_header Vary \"Authorization, Accept\";\n}\n```\n\n### Cache-Control Cheat Sheet\n\n| Header | Meaning |\n|--------|---------|\n| `public, max-age=31536000, immutable` | Cache for 1 year, never revalidate (hashed assets) |\n| `public, max-age=86400, must-revalidate` | Cache 1 day, check freshness after |\n| `private, max-age=600` | Browser cache only, 10 min (user-specific content) |\n| `no-cache` | Always revalidate with origin before serving |\n| `no-store` | Never cache (sensitive data) |\n| `s-maxage=3600` | CDN caches for 1 hour, overrides `max-age` for shared caches |\n\n## Cache Warming\n\n```bash\n# Warm cache for critical pages after deployment\n#!\u002Fbin\u002Fbash\nURLS=(\n  \"https:\u002F\u002Fwww.example.com\u002F\"\n  \"https:\u002F\u002Fwww.example.com\u002Fproducts\"\n  \"https:\u002F\u002Fwww.example.com\u002Fabout\"\n  \"https:\u002F\u002Fwww.example.com\u002Fcss\u002Fmain.abc123.css\"\n  \"https:\u002F\u002Fwww.example.com\u002Fjs\u002Fapp.def456.js\"\n)\n\nfor url in \"${URLS[@]}\"; do\n  curl -s -o \u002Fdev\u002Fnull -w \"%{http_code} %{time_total}s %{url_effective}\\n\" \"$url\"\ndone\n```\n\n## Monitoring Cache Performance\n\n```bash\n# Check cache status from response headers\ncurl -sI https:\u002F\u002Fwww.example.com\u002Fstyle.css | grep -i -E \"cf-cache|x-cache|age|cache-control\"\n\n# Expected headers:\n# cf-cache-status: HIT (Cloudflare)\n# x-cache: Hit from cloudfront (CloudFront)\n# age: 3600 (seconds since cached)\n\n# CloudFront cache hit ratio\naws cloudwatch get-metric-statistics \\\n  --namespace AWS\u002FCloudFront \\\n  --metric-name CacheHitRate \\\n  --dimensions Name=DistributionId,Value=E1A2B3C4D5E6F7 \\\n  --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S) \\\n  --end-time $(date -u +%Y-%m-%dT%H:%M:%S) \\\n  --period 300 \\\n  --statistics Average\n```\n\n## Troubleshooting\n\n| Symptom | Cause | Fix |\n|---------|-------|-----|\n| `cf-cache-status: DYNAMIC` | No cache rule matches or Cache-Control prevents it | Set `s-maxage` or create a cache rule for the path |\n| Cache hit ratio below 50% | Low TTLs or high URL cardinality (query strings) | Increase TTL; strip unnecessary query strings in cache key |\n| Stale content after deploy | Old objects still cached at edge | Invalidate; use content-hashed filenames to avoid this entirely |\n| CORS errors through CDN | CDN strips or caches wrong `Vary` header | Add `Vary: Origin` and configure origin request policy to forward `Origin` |\n| 502 errors from CDN | Origin down or timeout | Check origin health; increase CDN origin timeout settings |\n| Mixed content warnings | CDN serves HTTPS but origin links use HTTP | Set `viewer-protocol-policy: redirect-to-https`; fix origin URLs |\n| High invalidation costs | Purging `\u002F*` on every deploy | Use fingerprinted filenames; only invalidate `index.html` |\n\n## Related Skills\n\n- dns-management (`dns-management`) - DNS records for CDN CNAME setup\n- cloudflare-pages (`cloudflare-pages`) - Cloudflare's built-in CDN for Pages projects\n- reverse-proxy (`reverse-proxy`) - Origin server configuration behind CDN\n- load-balancing (`load-balancing`) - Multi-origin CDN backends\n\n## Limitations\n\n- Infrastructure commands can disrupt services: confirm target host\u002Fscope and have backups\u002Fsnapshots before mutating state.\n- Docs-only import: upstream scripts and templates not bundled.\n\n",{"name":5,"risk":26,"source":43,"license":14,"category":44,"metadata":45,"date_added":48,"description":7,"source_repo":49,"source_type":30,"compatibility":50,"license_source":51},"https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills","devops",{"author":46,"version":47},"devops-skills","1.0","2026-09-20","BagelHole\u002FDevOps-Security-Agent-Skills","Requires the relevant OS\u002Fplatform tooling and privileged access where noted. Docs-only; helper scripts and templates not bundled.","https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE","f3312ba749561b6159f477dbfc9313c875d40a56",".agents\u002Fskills_archive\u002Fcdn-setup","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612","2026-10-25 23:50:58",{"source":8,"skillName":5,"commands":58,"prompt":68,"zipAvailable":69},[59,62,65],{"tool":60,"command":61},"npx","npx skills add duc-duy-1612\u002FOnline-Delivery-Systems-Web --skill cdn-setup",{"tool":63,"command":64},"bunx","bunx skills add duc-duy-1612\u002FOnline-Delivery-Systems-Web --skill cdn-setup",{"tool":66,"command":67},"pnpm","pnpm dlx skills add duc-duy-1612\u002FOnline-Delivery-Systems-Web --skill cdn-setup","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fcdn-setup\u002FSKILL.md",true,[],[72,94,118,143,171,195],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":83,"publishedAt":38},"01M6Q0FA5FZ410Z33Z3TFQ4DBA","zero-trust","Implement zero-trust network architecture. Configure identity-based access, micro-segmentation, and continuous verification. Use when implementing modern security architectures.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fzero-trust\u002FSKILL.md",[78],{"categoryNo":79,"categoryName":80,"taxonomyType":81,"taxonomyTypeDesc":82},"01JBSEEDCAT000000000000011","运维与部署","SCENARIO","使用场景",[84,85,86,87,88,89,74,90,35,34,33,32,30,29,91,26,92,25,23,93],"ZeRO","trust","zero trust","architecture","assessment","verification","segmentation","active","scope","implementing",{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":38},"01M6Q0F1YZJW3KX5FBKEVZ8CV4","zcode-delegate","Delegate coding tasks to the Z.AI ZCode CLI only when the user explicitly requests it, while the orchestrator retains review and landing responsibility.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fzcode-delegate\u002FSKILL.md",[],[101,102,103,104,105,106,107,108,109,110,111,112,113,32,114,30,115,116,26,117],"delegate","zcode","zcode delegate","review","cli","orchestration","tasks","run","Bash","model","node","read","orchestrator","files","desktop app","app","agent-orchestration",{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":38},"01M6Q0ETK41VGNMYEXW0T00AJN","youtube-transcript","Fetch YouTube transcripts through DeepAPI or local fallback tooling and save clean text output.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fyoutube-transcript\u002FSKILL.md",[],[125,126,127,128,129,130,131,132,133,134,135,136,137,30,29,138,139,140,141,142],"transcript","youtube transcript","youtube","safe","github","codex","research","license","https","text","fetch","tooling","clean","local","output","deepapi","youtube transcripts","blob",{"skillNo":144,"name":145,"nameZh":6,"description":146,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":147,"categories":148,"keywords":160,"publishedAt":38},"01M6Q0EPPH2PVMDW40017F8WX0","youtube-transcript-skills","Fetch YouTube video transcripts, search videos\u002Fchannels, browse channels, and extract playlists via the getyoutubetranscript.com API - free tier, no card required.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fyoutube-transcript-skills\u002FSKILL.md",[149,152,155],{"categoryNo":150,"categoryName":151,"taxonomyType":81,"taxonomyTypeDesc":82},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":153,"categoryName":154,"taxonomyType":81,"taxonomyTypeDesc":82},"01JBSEEDCAT000000000000016","图像与多媒体",{"categoryNo":156,"categoryName":157,"taxonomyType":158,"taxonomyTypeDesc":159},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[125,126,127,161,128,162,129,130,132,163,164,165,166,135,167,30,29,168,169,170],"youtube transcript skills","gemini","search","api","Video","browse","api-integration","free","card","channels",{"skillNo":172,"name":173,"nameZh":6,"description":174,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":175,"categories":176,"keywords":181,"publishedAt":38},"01M6Q0EAB96PX83W5PTE8A0R8D","youtube-notetaker","Turn YouTube talks into local study notes with slides, transcripts, editable annotations, and a markdown-backed viewer.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fyoutube-notetaker\u002FSKILL.md",[177,180],{"categoryNo":178,"categoryName":179,"taxonomyType":81,"taxonomyTypeDesc":82},"01JBSEEDCAT000000000000003","演示文稿",{"categoryNo":153,"categoryName":154,"taxonomyType":81,"taxonomyTypeDesc":82},[127,182,183,105,128,184,185,186,187,132,165,188,189,190,191,29,192,138,193,194],"youtube notetaker","notetaker","workflow","official","notes","code","markdown","slides","annotations","README","study","dair-academy","viewer",{"skillNo":196,"name":197,"nameZh":6,"description":198,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":199,"categories":200,"keywords":202,"publishedAt":38},"01M6Q0E55F0GW5MX48V8HXS8B5","youtube-full","Fetch YouTube transcripts, search videos, browse channels, and extract playlists via TranscriptAPI — no yt-dlp, no Google API key, works from any cloud server.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fyoutube-full\u002FSKILL.md",[201],{"categoryNo":150,"categoryName":151,"taxonomyType":81,"taxonomyTypeDesc":82},[203,127,204,205,128,162,163,206,207,164,165,166,135,208,167,30,29,168,209,141],"youtube full","full","google","server","dlp","credits","automatic"]