Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/argo-smart-routing/patterns.md
1# Integration Patterns23## Enable Argo + Tiered Cache45```typescript6async function enableOptimalPerformance(client: Cloudflare, zoneId: string) {7await Promise.all([8client.argo.smartRouting.edit({ zone_id: zoneId, value: 'on' }),9client.argo.tieredCaching.edit({ zone_id: zoneId, value: 'on' }),10]);11}12```1314**Flow:** Visitor → Edge (Lower-Tier) → [Cache Miss] → Upper-Tier → [Cache Miss + Argo] → Origin1516**Impact:** Argo ~30% latency reduction + Tiered Cache 50-80% origin offload1718## Usage Analytics (GraphQL)1920```graphql21query ArgoAnalytics($zoneTag: string!) {22viewer {23zones(filter: { zoneTag: $zoneTag }) {24httpRequestsAdaptiveGroups(limit: 1000) {25sum { argoBytes, bytes }26}27}28}29}30```3132**Billing:** ~$0.10/GB. DDoS-mitigated and WAF-blocked traffic NOT charged.3334## Spectrum TCP Integration3536Enable Argo for non-HTTP traffic (databases, game servers, IoT):3738```typescript39// Update existing app40await client.spectrum.apps.update(appId, { zone_id: zoneId, argo_smart_routing: true });4142// Create new app with Argo43await client.spectrum.apps.create({44zone_id: zoneId,45dns: { type: 'CNAME', name: 'tcp.example.com' },46origin_direct: ['tcp://origin.example.com:3306'],47protocol: 'tcp/3306',48argo_smart_routing: true,49});50```5152**Use cases:** MySQL/PostgreSQL (3306/5432), game servers, MQTT (1883), SSH (22)5354## Pre-Flight Validation5556```typescript57async function validateArgoEligibility(client: Cloudflare, zoneId: string) {58const status = await client.argo.smartRouting.get({ zone_id: zoneId });59const zone = await client.zones.get({ zone_id: zoneId });6061const issues: string[] = [];62if (!status.editable) issues.push('Zone not editable');63if (['free', 'pro'].includes(zone.plan.legacy_id)) issues.push('Requires Business+ plan');64if (zone.status !== 'active') issues.push('Zone not active');6566return { canEnable: issues.length === 0, issues };67}68```6970## Post-Enable Verification7172```typescript73async function verifyArgoEnabled(client: Cloudflare, zoneId: string): Promise<boolean> {74await new Promise(r => setTimeout(r, 2000)); // Wait for propagation75const status = await client.argo.smartRouting.get({ zone_id: zoneId });76return status.value === 'on';77}78```7980## Full Setup Pattern8182```typescript83async function setupArgo(client: Cloudflare, zoneId: string) {84// 1. Validate85const { canEnable, issues } = await validateArgoEligibility(client, zoneId);86if (!canEnable) throw new Error(issues.join(', '));8788// 2. Enable both features89await Promise.all([90client.argo.smartRouting.edit({ zone_id: zoneId, value: 'on' }),91client.argo.tieredCaching.edit({ zone_id: zoneId, value: 'on' }),92]);9394// 3. Verify95const [argo, cache] = await Promise.all([96client.argo.smartRouting.get({ zone_id: zoneId }),97client.argo.tieredCaching.get({ zone_id: zoneId }),98]);99100return { argo: argo.value === 'on', tieredCache: cache.value === 'on' };101}102```103104**When to combine:** High-traffic sites (>1TB/mo), global users, cacheable content.105