@wazir-dev/cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +111 -0
- package/CHANGELOG.md +14 -0
- package/CONTRIBUTING.md +101 -0
- package/LICENSE +21 -0
- package/README.md +314 -0
- package/assets/composition-engine.mmd +34 -0
- package/assets/demo-script.sh +17 -0
- package/assets/logo-dark.svg +14 -0
- package/assets/logo.svg +14 -0
- package/assets/pipeline.mmd +39 -0
- package/assets/record-demo.sh +51 -0
- package/docs/README.md +51 -0
- package/docs/adapters/context-mode.md +60 -0
- package/docs/concepts/architecture.md +87 -0
- package/docs/concepts/artifact-model.md +60 -0
- package/docs/concepts/composition-engine.md +36 -0
- package/docs/concepts/indexing-and-recall.md +160 -0
- package/docs/concepts/observability.md +41 -0
- package/docs/concepts/roles-and-workflows.md +59 -0
- package/docs/concepts/terminology-policy.md +27 -0
- package/docs/getting-started/01-installation.md +78 -0
- package/docs/getting-started/02-first-run.md +102 -0
- package/docs/getting-started/03-adding-to-project.md +15 -0
- package/docs/getting-started/04-host-setup.md +15 -0
- package/docs/guides/ci-integration.md +15 -0
- package/docs/guides/creating-skills.md +15 -0
- package/docs/guides/expertise-module-authoring.md +15 -0
- package/docs/guides/hook-development.md +15 -0
- package/docs/guides/memory-and-learnings.md +34 -0
- package/docs/guides/multi-host-export.md +15 -0
- package/docs/guides/troubleshooting.md +101 -0
- package/docs/guides/writing-custom-roles.md +15 -0
- package/docs/plans/2026-03-15-cli-pipeline-integration-design.md +592 -0
- package/docs/plans/2026-03-15-cli-pipeline-integration-plan.md +598 -0
- package/docs/plans/2026-03-15-docs-enforcement-plan.md +238 -0
- package/docs/readmes/INDEX.md +99 -0
- package/docs/readmes/features/expertise/README.md +171 -0
- package/docs/readmes/features/exports/README.md +222 -0
- package/docs/readmes/features/hooks/README.md +103 -0
- package/docs/readmes/features/hooks/loop-cap-guard.md +133 -0
- package/docs/readmes/features/hooks/post-tool-capture.md +121 -0
- package/docs/readmes/features/hooks/post-tool-lint.md +130 -0
- package/docs/readmes/features/hooks/pre-compact-summary.md +122 -0
- package/docs/readmes/features/hooks/pre-tool-capture-route.md +100 -0
- package/docs/readmes/features/hooks/protected-path-write-guard.md +128 -0
- package/docs/readmes/features/hooks/session-start.md +119 -0
- package/docs/readmes/features/hooks/stop-handoff-harvest.md +125 -0
- package/docs/readmes/features/roles/README.md +157 -0
- package/docs/readmes/features/roles/clarifier.md +152 -0
- package/docs/readmes/features/roles/content-author.md +190 -0
- package/docs/readmes/features/roles/designer.md +193 -0
- package/docs/readmes/features/roles/executor.md +184 -0
- package/docs/readmes/features/roles/learner.md +210 -0
- package/docs/readmes/features/roles/planner.md +182 -0
- package/docs/readmes/features/roles/researcher.md +164 -0
- package/docs/readmes/features/roles/reviewer.md +184 -0
- package/docs/readmes/features/roles/specifier.md +162 -0
- package/docs/readmes/features/roles/verifier.md +215 -0
- package/docs/readmes/features/schemas/README.md +178 -0
- package/docs/readmes/features/skills/README.md +63 -0
- package/docs/readmes/features/skills/brainstorming.md +96 -0
- package/docs/readmes/features/skills/debugging.md +148 -0
- package/docs/readmes/features/skills/design.md +120 -0
- package/docs/readmes/features/skills/prepare-next.md +109 -0
- package/docs/readmes/features/skills/run-audit.md +159 -0
- package/docs/readmes/features/skills/scan-project.md +109 -0
- package/docs/readmes/features/skills/self-audit.md +176 -0
- package/docs/readmes/features/skills/tdd.md +137 -0
- package/docs/readmes/features/skills/using-skills.md +92 -0
- package/docs/readmes/features/skills/verification.md +120 -0
- package/docs/readmes/features/skills/writing-plans.md +104 -0
- package/docs/readmes/features/tooling/README.md +320 -0
- package/docs/readmes/features/workflows/README.md +186 -0
- package/docs/readmes/features/workflows/author.md +181 -0
- package/docs/readmes/features/workflows/clarify.md +154 -0
- package/docs/readmes/features/workflows/design-review.md +171 -0
- package/docs/readmes/features/workflows/design.md +169 -0
- package/docs/readmes/features/workflows/discover.md +162 -0
- package/docs/readmes/features/workflows/execute.md +173 -0
- package/docs/readmes/features/workflows/learn.md +167 -0
- package/docs/readmes/features/workflows/plan-review.md +165 -0
- package/docs/readmes/features/workflows/plan.md +170 -0
- package/docs/readmes/features/workflows/prepare-next.md +167 -0
- package/docs/readmes/features/workflows/review.md +169 -0
- package/docs/readmes/features/workflows/run-audit.md +191 -0
- package/docs/readmes/features/workflows/spec-challenge.md +159 -0
- package/docs/readmes/features/workflows/specify.md +160 -0
- package/docs/readmes/features/workflows/verify.md +177 -0
- package/docs/readmes/packages/README.md +50 -0
- package/docs/readmes/packages/ajv.md +117 -0
- package/docs/readmes/packages/context-mode.md +118 -0
- package/docs/readmes/packages/gray-matter.md +116 -0
- package/docs/readmes/packages/node-test.md +137 -0
- package/docs/readmes/packages/yaml.md +112 -0
- package/docs/reference/configuration-reference.md +159 -0
- package/docs/reference/expertise-index.md +52 -0
- package/docs/reference/git-flow.md +43 -0
- package/docs/reference/hooks.md +87 -0
- package/docs/reference/host-exports.md +50 -0
- package/docs/reference/launch-checklist.md +172 -0
- package/docs/reference/marketplace-listings.md +76 -0
- package/docs/reference/release-process.md +34 -0
- package/docs/reference/roles-reference.md +77 -0
- package/docs/reference/skills.md +33 -0
- package/docs/reference/templates.md +29 -0
- package/docs/reference/tooling-cli.md +94 -0
- package/docs/truth-claims.yaml +222 -0
- package/expertise/PROGRESS.md +63 -0
- package/expertise/README.md +18 -0
- package/expertise/antipatterns/PROGRESS.md +56 -0
- package/expertise/antipatterns/backend/api-design-antipatterns.md +1271 -0
- package/expertise/antipatterns/backend/auth-antipatterns.md +1195 -0
- package/expertise/antipatterns/backend/caching-antipatterns.md +622 -0
- package/expertise/antipatterns/backend/database-antipatterns.md +1038 -0
- package/expertise/antipatterns/backend/index.md +24 -0
- package/expertise/antipatterns/backend/microservices-antipatterns.md +850 -0
- package/expertise/antipatterns/code/architecture-antipatterns.md +919 -0
- package/expertise/antipatterns/code/async-antipatterns.md +622 -0
- package/expertise/antipatterns/code/code-smells.md +1186 -0
- package/expertise/antipatterns/code/dependency-antipatterns.md +1209 -0
- package/expertise/antipatterns/code/error-handling-antipatterns.md +1360 -0
- package/expertise/antipatterns/code/index.md +27 -0
- package/expertise/antipatterns/code/naming-and-abstraction.md +1118 -0
- package/expertise/antipatterns/code/state-management-antipatterns.md +1076 -0
- package/expertise/antipatterns/code/testing-antipatterns.md +1053 -0
- package/expertise/antipatterns/design/accessibility-antipatterns.md +1136 -0
- package/expertise/antipatterns/design/dark-patterns.md +1121 -0
- package/expertise/antipatterns/design/index.md +22 -0
- package/expertise/antipatterns/design/ui-antipatterns.md +1202 -0
- package/expertise/antipatterns/design/ux-antipatterns.md +680 -0
- package/expertise/antipatterns/frontend/css-layout-antipatterns.md +691 -0
- package/expertise/antipatterns/frontend/flutter-antipatterns.md +1827 -0
- package/expertise/antipatterns/frontend/index.md +23 -0
- package/expertise/antipatterns/frontend/mobile-antipatterns.md +573 -0
- package/expertise/antipatterns/frontend/react-antipatterns.md +1128 -0
- package/expertise/antipatterns/frontend/spa-antipatterns.md +1235 -0
- package/expertise/antipatterns/index.md +31 -0
- package/expertise/antipatterns/performance/index.md +20 -0
- package/expertise/antipatterns/performance/performance-antipatterns.md +1013 -0
- package/expertise/antipatterns/performance/premature-optimization.md +623 -0
- package/expertise/antipatterns/performance/scaling-antipatterns.md +785 -0
- package/expertise/antipatterns/process/ai-coding-antipatterns.md +853 -0
- package/expertise/antipatterns/process/code-review-antipatterns.md +656 -0
- package/expertise/antipatterns/process/deployment-antipatterns.md +920 -0
- package/expertise/antipatterns/process/index.md +23 -0
- package/expertise/antipatterns/process/technical-debt-antipatterns.md +647 -0
- package/expertise/antipatterns/security/index.md +20 -0
- package/expertise/antipatterns/security/secrets-antipatterns.md +849 -0
- package/expertise/antipatterns/security/security-theater.md +843 -0
- package/expertise/antipatterns/security/vulnerability-patterns.md +801 -0
- package/expertise/architecture/PROGRESS.md +70 -0
- package/expertise/architecture/data/caching-architecture.md +671 -0
- package/expertise/architecture/data/data-consistency.md +574 -0
- package/expertise/architecture/data/data-modeling.md +536 -0
- package/expertise/architecture/data/event-streams-and-queues.md +634 -0
- package/expertise/architecture/data/index.md +25 -0
- package/expertise/architecture/data/search-architecture.md +663 -0
- package/expertise/architecture/data/sql-vs-nosql.md +708 -0
- package/expertise/architecture/decisions/architecture-decision-records.md +640 -0
- package/expertise/architecture/decisions/build-vs-buy.md +616 -0
- package/expertise/architecture/decisions/index.md +23 -0
- package/expertise/architecture/decisions/monolith-to-microservices.md +790 -0
- package/expertise/architecture/decisions/technology-selection.md +616 -0
- package/expertise/architecture/distributed/cap-theorem-and-tradeoffs.md +800 -0
- package/expertise/architecture/distributed/circuit-breaker-bulkhead.md +741 -0
- package/expertise/architecture/distributed/consensus-and-coordination.md +796 -0
- package/expertise/architecture/distributed/distributed-systems-fundamentals.md +564 -0
- package/expertise/architecture/distributed/idempotency-and-retry.md +796 -0
- package/expertise/architecture/distributed/index.md +25 -0
- package/expertise/architecture/distributed/saga-pattern.md +797 -0
- package/expertise/architecture/foundations/architectural-thinking.md +460 -0
- package/expertise/architecture/foundations/coupling-and-cohesion.md +770 -0
- package/expertise/architecture/foundations/design-principles-solid.md +649 -0
- package/expertise/architecture/foundations/domain-driven-design.md +719 -0
- package/expertise/architecture/foundations/index.md +25 -0
- package/expertise/architecture/foundations/separation-of-concerns.md +472 -0
- package/expertise/architecture/foundations/twelve-factor-app.md +797 -0
- package/expertise/architecture/index.md +34 -0
- package/expertise/architecture/integration/api-design-graphql.md +638 -0
- package/expertise/architecture/integration/api-design-grpc.md +804 -0
- package/expertise/architecture/integration/api-design-rest.md +892 -0
- package/expertise/architecture/integration/index.md +25 -0
- package/expertise/architecture/integration/third-party-integration.md +795 -0
- package/expertise/architecture/integration/webhooks-and-callbacks.md +1152 -0
- package/expertise/architecture/integration/websockets-realtime.md +791 -0
- package/expertise/architecture/mobile-architecture/index.md +22 -0
- package/expertise/architecture/mobile-architecture/mobile-app-architecture.md +780 -0
- package/expertise/architecture/mobile-architecture/mobile-backend-for-frontend.md +670 -0
- package/expertise/architecture/mobile-architecture/offline-first.md +719 -0
- package/expertise/architecture/mobile-architecture/push-and-sync.md +782 -0
- package/expertise/architecture/patterns/cqrs-event-sourcing.md +717 -0
- package/expertise/architecture/patterns/event-driven.md +797 -0
- package/expertise/architecture/patterns/hexagonal-clean-architecture.md +870 -0
- package/expertise/architecture/patterns/index.md +27 -0
- package/expertise/architecture/patterns/layered-architecture.md +736 -0
- package/expertise/architecture/patterns/microservices.md +753 -0
- package/expertise/architecture/patterns/modular-monolith.md +692 -0
- package/expertise/architecture/patterns/monolith.md +626 -0
- package/expertise/architecture/patterns/plugin-architecture.md +735 -0
- package/expertise/architecture/patterns/serverless.md +780 -0
- package/expertise/architecture/scaling/database-scaling.md +615 -0
- package/expertise/architecture/scaling/feature-flags-and-rollouts.md +757 -0
- package/expertise/architecture/scaling/horizontal-vs-vertical.md +606 -0
- package/expertise/architecture/scaling/index.md +24 -0
- package/expertise/architecture/scaling/multi-tenancy.md +800 -0
- package/expertise/architecture/scaling/stateless-design.md +787 -0
- package/expertise/backend/embedded-firmware.md +625 -0
- package/expertise/backend/go.md +853 -0
- package/expertise/backend/index.md +24 -0
- package/expertise/backend/java-spring.md +448 -0
- package/expertise/backend/node-typescript.md +625 -0
- package/expertise/backend/python-fastapi.md +724 -0
- package/expertise/backend/rust.md +458 -0
- package/expertise/backend/solidity.md +711 -0
- package/expertise/composition-map.yaml +443 -0
- package/expertise/content/foundations/content-modeling.md +395 -0
- package/expertise/content/foundations/editorial-standards.md +449 -0
- package/expertise/content/foundations/index.md +24 -0
- package/expertise/content/foundations/microcopy.md +455 -0
- package/expertise/content/foundations/terminology-governance.md +509 -0
- package/expertise/content/index.md +34 -0
- package/expertise/content/patterns/accessibility-copy.md +518 -0
- package/expertise/content/patterns/index.md +24 -0
- package/expertise/content/patterns/notification-content.md +433 -0
- package/expertise/content/patterns/sample-content.md +486 -0
- package/expertise/content/patterns/state-copy.md +439 -0
- package/expertise/design/PROGRESS.md +58 -0
- package/expertise/design/disciplines/dark-mode-theming.md +577 -0
- package/expertise/design/disciplines/design-systems.md +595 -0
- package/expertise/design/disciplines/index.md +25 -0
- package/expertise/design/disciplines/information-architecture.md +800 -0
- package/expertise/design/disciplines/interaction-design.md +788 -0
- package/expertise/design/disciplines/responsive-design.md +552 -0
- package/expertise/design/disciplines/usability-testing.md +516 -0
- package/expertise/design/disciplines/user-research.md +792 -0
- package/expertise/design/foundations/accessibility-design.md +796 -0
- package/expertise/design/foundations/color-theory.md +797 -0
- package/expertise/design/foundations/iconography.md +795 -0
- package/expertise/design/foundations/index.md +26 -0
- package/expertise/design/foundations/motion-and-animation.md +653 -0
- package/expertise/design/foundations/rtl-design.md +585 -0
- package/expertise/design/foundations/spacing-and-layout.md +607 -0
- package/expertise/design/foundations/typography.md +800 -0
- package/expertise/design/foundations/visual-hierarchy.md +761 -0
- package/expertise/design/index.md +32 -0
- package/expertise/design/patterns/authentication-flows.md +474 -0
- package/expertise/design/patterns/content-consumption.md +789 -0
- package/expertise/design/patterns/data-display.md +618 -0
- package/expertise/design/patterns/e-commerce.md +1494 -0
- package/expertise/design/patterns/feedback-and-states.md +642 -0
- package/expertise/design/patterns/forms-and-input.md +819 -0
- package/expertise/design/patterns/gamification.md +801 -0
- package/expertise/design/patterns/index.md +31 -0
- package/expertise/design/patterns/microinteractions.md +449 -0
- package/expertise/design/patterns/navigation.md +800 -0
- package/expertise/design/patterns/notifications.md +705 -0
- package/expertise/design/patterns/onboarding.md +700 -0
- package/expertise/design/patterns/search-and-filter.md +601 -0
- package/expertise/design/patterns/settings-and-preferences.md +768 -0
- package/expertise/design/patterns/social-and-community.md +748 -0
- package/expertise/design/platforms/desktop-native.md +612 -0
- package/expertise/design/platforms/index.md +25 -0
- package/expertise/design/platforms/mobile-android.md +825 -0
- package/expertise/design/platforms/mobile-cross-platform.md +983 -0
- package/expertise/design/platforms/mobile-ios.md +699 -0
- package/expertise/design/platforms/tablet.md +794 -0
- package/expertise/design/platforms/web-dashboard.md +790 -0
- package/expertise/design/platforms/web-responsive.md +550 -0
- package/expertise/design/psychology/behavioral-nudges.md +449 -0
- package/expertise/design/psychology/cognitive-load.md +1191 -0
- package/expertise/design/psychology/error-psychology.md +778 -0
- package/expertise/design/psychology/index.md +22 -0
- package/expertise/design/psychology/persuasive-design.md +736 -0
- package/expertise/design/psychology/user-mental-models.md +623 -0
- package/expertise/design/tooling/open-pencil.md +266 -0
- package/expertise/frontend/angular.md +1073 -0
- package/expertise/frontend/desktop-electron.md +546 -0
- package/expertise/frontend/flutter.md +782 -0
- package/expertise/frontend/index.md +27 -0
- package/expertise/frontend/native-android.md +409 -0
- package/expertise/frontend/native-ios.md +490 -0
- package/expertise/frontend/react-native.md +1160 -0
- package/expertise/frontend/react.md +808 -0
- package/expertise/frontend/vue.md +1089 -0
- package/expertise/humanize/domain-rules-code.md +79 -0
- package/expertise/humanize/domain-rules-content.md +67 -0
- package/expertise/humanize/domain-rules-technical-docs.md +56 -0
- package/expertise/humanize/index.md +35 -0
- package/expertise/humanize/self-audit-checklist.md +87 -0
- package/expertise/humanize/sentence-patterns.md +218 -0
- package/expertise/humanize/vocabulary-blacklist.md +105 -0
- package/expertise/i18n/PROGRESS.md +65 -0
- package/expertise/i18n/advanced/accessibility-and-i18n.md +28 -0
- package/expertise/i18n/advanced/bidirectional-text-algorithm.md +38 -0
- package/expertise/i18n/advanced/complex-scripts.md +30 -0
- package/expertise/i18n/advanced/performance-and-i18n.md +27 -0
- package/expertise/i18n/advanced/testing-i18n.md +28 -0
- package/expertise/i18n/content/content-adaptation.md +23 -0
- package/expertise/i18n/content/locale-specific-formatting.md +23 -0
- package/expertise/i18n/content/machine-translation-integration.md +28 -0
- package/expertise/i18n/content/translation-management.md +29 -0
- package/expertise/i18n/foundations/date-time-calendars.md +67 -0
- package/expertise/i18n/foundations/i18n-architecture.md +272 -0
- package/expertise/i18n/foundations/locale-and-language-tags.md +79 -0
- package/expertise/i18n/foundations/numbers-currency-units.md +61 -0
- package/expertise/i18n/foundations/pluralization-and-gender.md +109 -0
- package/expertise/i18n/foundations/string-externalization.md +236 -0
- package/expertise/i18n/foundations/text-direction-bidi.md +241 -0
- package/expertise/i18n/foundations/unicode-and-encoding.md +86 -0
- package/expertise/i18n/index.md +38 -0
- package/expertise/i18n/platform/backend-i18n.md +31 -0
- package/expertise/i18n/platform/flutter-i18n.md +148 -0
- package/expertise/i18n/platform/native-android-i18n.md +36 -0
- package/expertise/i18n/platform/native-ios-i18n.md +36 -0
- package/expertise/i18n/platform/react-i18n.md +103 -0
- package/expertise/i18n/platform/web-css-i18n.md +81 -0
- package/expertise/i18n/rtl/arabic-specific.md +175 -0
- package/expertise/i18n/rtl/hebrew-specific.md +149 -0
- package/expertise/i18n/rtl/rtl-animations-and-transitions.md +111 -0
- package/expertise/i18n/rtl/rtl-forms-and-input.md +161 -0
- package/expertise/i18n/rtl/rtl-fundamentals.md +211 -0
- package/expertise/i18n/rtl/rtl-icons-and-images.md +181 -0
- package/expertise/i18n/rtl/rtl-layout-mirroring.md +252 -0
- package/expertise/i18n/rtl/rtl-navigation-and-gestures.md +107 -0
- package/expertise/i18n/rtl/rtl-testing-and-qa.md +147 -0
- package/expertise/i18n/rtl/rtl-typography.md +160 -0
- package/expertise/index.md +113 -0
- package/expertise/index.yaml +216 -0
- package/expertise/infrastructure/cloud-aws.md +597 -0
- package/expertise/infrastructure/cloud-gcp.md +599 -0
- package/expertise/infrastructure/cybersecurity.md +816 -0
- package/expertise/infrastructure/database-mongodb.md +447 -0
- package/expertise/infrastructure/database-postgres.md +400 -0
- package/expertise/infrastructure/devops-cicd.md +787 -0
- package/expertise/infrastructure/index.md +27 -0
- package/expertise/performance/PROGRESS.md +50 -0
- package/expertise/performance/backend/api-latency.md +1204 -0
- package/expertise/performance/backend/background-jobs.md +506 -0
- package/expertise/performance/backend/connection-pooling.md +1209 -0
- package/expertise/performance/backend/database-query-optimization.md +515 -0
- package/expertise/performance/backend/index.md +23 -0
- package/expertise/performance/backend/rate-limiting-and-throttling.md +971 -0
- package/expertise/performance/foundations/algorithmic-complexity.md +954 -0
- package/expertise/performance/foundations/caching-strategies.md +489 -0
- package/expertise/performance/foundations/concurrency-and-parallelism.md +847 -0
- package/expertise/performance/foundations/index.md +24 -0
- package/expertise/performance/foundations/measuring-and-profiling.md +440 -0
- package/expertise/performance/foundations/memory-management.md +964 -0
- package/expertise/performance/foundations/performance-budgets.md +1314 -0
- package/expertise/performance/index.md +31 -0
- package/expertise/performance/infrastructure/auto-scaling.md +1059 -0
- package/expertise/performance/infrastructure/cdn-and-edge.md +1081 -0
- package/expertise/performance/infrastructure/index.md +22 -0
- package/expertise/performance/infrastructure/load-balancing.md +1081 -0
- package/expertise/performance/infrastructure/observability.md +1079 -0
- package/expertise/performance/mobile/index.md +23 -0
- package/expertise/performance/mobile/mobile-animations.md +544 -0
- package/expertise/performance/mobile/mobile-memory-battery.md +416 -0
- package/expertise/performance/mobile/mobile-network.md +452 -0
- package/expertise/performance/mobile/mobile-rendering.md +599 -0
- package/expertise/performance/mobile/mobile-startup-time.md +505 -0
- package/expertise/performance/platform-specific/flutter-performance.md +647 -0
- package/expertise/performance/platform-specific/index.md +22 -0
- package/expertise/performance/platform-specific/node-performance.md +1307 -0
- package/expertise/performance/platform-specific/postgres-performance.md +1366 -0
- package/expertise/performance/platform-specific/react-performance.md +1403 -0
- package/expertise/performance/web/bundle-optimization.md +1239 -0
- package/expertise/performance/web/image-and-media.md +636 -0
- package/expertise/performance/web/index.md +24 -0
- package/expertise/performance/web/network-optimization.md +1133 -0
- package/expertise/performance/web/rendering-performance.md +1098 -0
- package/expertise/performance/web/ssr-and-hydration.md +918 -0
- package/expertise/performance/web/web-vitals.md +1374 -0
- package/expertise/quality/accessibility.md +985 -0
- package/expertise/quality/evidence-based-verification.md +499 -0
- package/expertise/quality/index.md +24 -0
- package/expertise/quality/ml-model-audit.md +614 -0
- package/expertise/quality/performance.md +600 -0
- package/expertise/quality/testing-api.md +891 -0
- package/expertise/quality/testing-mobile.md +496 -0
- package/expertise/quality/testing-web.md +849 -0
- package/expertise/security/PROGRESS.md +54 -0
- package/expertise/security/agentic-identity.md +540 -0
- package/expertise/security/compliance-frameworks.md +601 -0
- package/expertise/security/data/data-encryption.md +364 -0
- package/expertise/security/data/data-privacy-gdpr.md +692 -0
- package/expertise/security/data/database-security.md +1171 -0
- package/expertise/security/data/index.md +22 -0
- package/expertise/security/data/pii-handling.md +531 -0
- package/expertise/security/foundations/authentication.md +1041 -0
- package/expertise/security/foundations/authorization.md +603 -0
- package/expertise/security/foundations/cryptography.md +1001 -0
- package/expertise/security/foundations/index.md +25 -0
- package/expertise/security/foundations/owasp-top-10.md +1354 -0
- package/expertise/security/foundations/secrets-management.md +1217 -0
- package/expertise/security/foundations/secure-sdlc.md +700 -0
- package/expertise/security/foundations/supply-chain-security.md +698 -0
- package/expertise/security/index.md +31 -0
- package/expertise/security/infrastructure/cloud-security-aws.md +1296 -0
- package/expertise/security/infrastructure/cloud-security-gcp.md +1376 -0
- package/expertise/security/infrastructure/container-security.md +721 -0
- package/expertise/security/infrastructure/incident-response.md +1295 -0
- package/expertise/security/infrastructure/index.md +24 -0
- package/expertise/security/infrastructure/logging-and-monitoring.md +1618 -0
- package/expertise/security/infrastructure/network-security.md +1337 -0
- package/expertise/security/mobile/index.md +23 -0
- package/expertise/security/mobile/mobile-android-security.md +1218 -0
- package/expertise/security/mobile/mobile-binary-protection.md +1229 -0
- package/expertise/security/mobile/mobile-data-storage.md +1265 -0
- package/expertise/security/mobile/mobile-ios-security.md +1401 -0
- package/expertise/security/mobile/mobile-network-security.md +1520 -0
- package/expertise/security/smart-contract-security.md +594 -0
- package/expertise/security/testing/index.md +22 -0
- package/expertise/security/testing/penetration-testing.md +1258 -0
- package/expertise/security/testing/security-code-review.md +1765 -0
- package/expertise/security/testing/threat-modeling.md +1074 -0
- package/expertise/security/testing/vulnerability-scanning.md +1062 -0
- package/expertise/security/web/api-security.md +586 -0
- package/expertise/security/web/cors-and-headers.md +433 -0
- package/expertise/security/web/csrf.md +562 -0
- package/expertise/security/web/file-upload.md +1477 -0
- package/expertise/security/web/index.md +25 -0
- package/expertise/security/web/injection.md +1375 -0
- package/expertise/security/web/session-management.md +1101 -0
- package/expertise/security/web/xss.md +1158 -0
- package/exports/README.md +17 -0
- package/exports/hosts/claude/.claude/agents/clarifier.md +42 -0
- package/exports/hosts/claude/.claude/agents/content-author.md +63 -0
- package/exports/hosts/claude/.claude/agents/designer.md +55 -0
- package/exports/hosts/claude/.claude/agents/executor.md +55 -0
- package/exports/hosts/claude/.claude/agents/learner.md +51 -0
- package/exports/hosts/claude/.claude/agents/planner.md +53 -0
- package/exports/hosts/claude/.claude/agents/researcher.md +43 -0
- package/exports/hosts/claude/.claude/agents/reviewer.md +54 -0
- package/exports/hosts/claude/.claude/agents/specifier.md +47 -0
- package/exports/hosts/claude/.claude/agents/verifier.md +71 -0
- package/exports/hosts/claude/.claude/commands/author.md +42 -0
- package/exports/hosts/claude/.claude/commands/clarify.md +38 -0
- package/exports/hosts/claude/.claude/commands/design-review.md +46 -0
- package/exports/hosts/claude/.claude/commands/design.md +44 -0
- package/exports/hosts/claude/.claude/commands/discover.md +37 -0
- package/exports/hosts/claude/.claude/commands/execute.md +48 -0
- package/exports/hosts/claude/.claude/commands/learn.md +38 -0
- package/exports/hosts/claude/.claude/commands/plan-review.md +42 -0
- package/exports/hosts/claude/.claude/commands/plan.md +39 -0
- package/exports/hosts/claude/.claude/commands/prepare-next.md +37 -0
- package/exports/hosts/claude/.claude/commands/review.md +40 -0
- package/exports/hosts/claude/.claude/commands/run-audit.md +41 -0
- package/exports/hosts/claude/.claude/commands/spec-challenge.md +41 -0
- package/exports/hosts/claude/.claude/commands/specify.md +38 -0
- package/exports/hosts/claude/.claude/commands/verify.md +37 -0
- package/exports/hosts/claude/.claude/settings.json +34 -0
- package/exports/hosts/claude/CLAUDE.md +19 -0
- package/exports/hosts/claude/export.manifest.json +38 -0
- package/exports/hosts/claude/host-package.json +67 -0
- package/exports/hosts/codex/AGENTS.md +19 -0
- package/exports/hosts/codex/export.manifest.json +38 -0
- package/exports/hosts/codex/host-package.json +41 -0
- package/exports/hosts/cursor/.cursor/hooks.json +16 -0
- package/exports/hosts/cursor/.cursor/rules/wazir-core.mdc +19 -0
- package/exports/hosts/cursor/export.manifest.json +38 -0
- package/exports/hosts/cursor/host-package.json +42 -0
- package/exports/hosts/gemini/GEMINI.md +19 -0
- package/exports/hosts/gemini/export.manifest.json +38 -0
- package/exports/hosts/gemini/host-package.json +41 -0
- package/hooks/README.md +18 -0
- package/hooks/definitions/loop_cap_guard.yaml +21 -0
- package/hooks/definitions/post_tool_capture.yaml +24 -0
- package/hooks/definitions/pre_compact_summary.yaml +19 -0
- package/hooks/definitions/pre_tool_capture_route.yaml +19 -0
- package/hooks/definitions/protected_path_write_guard.yaml +19 -0
- package/hooks/definitions/session_start.yaml +19 -0
- package/hooks/definitions/stop_handoff_harvest.yaml +20 -0
- package/hooks/loop-cap-guard +17 -0
- package/hooks/post-tool-lint +36 -0
- package/hooks/protected-path-write-guard +17 -0
- package/hooks/session-start +41 -0
- package/llms-full.txt +2355 -0
- package/llms.txt +43 -0
- package/package.json +79 -0
- package/roles/README.md +20 -0
- package/roles/clarifier.md +42 -0
- package/roles/content-author.md +63 -0
- package/roles/designer.md +55 -0
- package/roles/executor.md +55 -0
- package/roles/learner.md +51 -0
- package/roles/planner.md +53 -0
- package/roles/researcher.md +43 -0
- package/roles/reviewer.md +54 -0
- package/roles/specifier.md +47 -0
- package/roles/verifier.md +71 -0
- package/schemas/README.md +24 -0
- package/schemas/accepted-learning.schema.json +20 -0
- package/schemas/author-artifact.schema.json +156 -0
- package/schemas/clarification.schema.json +19 -0
- package/schemas/design-artifact.schema.json +80 -0
- package/schemas/docs-claim.schema.json +18 -0
- package/schemas/export-manifest.schema.json +20 -0
- package/schemas/hook.schema.json +67 -0
- package/schemas/host-export-package.schema.json +18 -0
- package/schemas/implementation-plan.schema.json +19 -0
- package/schemas/proposed-learning.schema.json +19 -0
- package/schemas/research.schema.json +18 -0
- package/schemas/review.schema.json +29 -0
- package/schemas/run-manifest.schema.json +18 -0
- package/schemas/spec-challenge.schema.json +18 -0
- package/schemas/spec.schema.json +20 -0
- package/schemas/usage.schema.json +102 -0
- package/schemas/verification-proof.schema.json +29 -0
- package/schemas/wazir-manifest.schema.json +173 -0
- package/skills/README.md +40 -0
- package/skills/brainstorming/SKILL.md +77 -0
- package/skills/debugging/SKILL.md +50 -0
- package/skills/design/SKILL.md +61 -0
- package/skills/dispatching-parallel-agents/SKILL.md +128 -0
- package/skills/executing-plans/SKILL.md +70 -0
- package/skills/finishing-a-development-branch/SKILL.md +169 -0
- package/skills/humanize/SKILL.md +123 -0
- package/skills/init-pipeline/SKILL.md +124 -0
- package/skills/prepare-next/SKILL.md +20 -0
- package/skills/receiving-code-review/SKILL.md +123 -0
- package/skills/requesting-code-review/SKILL.md +105 -0
- package/skills/requesting-code-review/code-reviewer.md +108 -0
- package/skills/run-audit/SKILL.md +197 -0
- package/skills/scan-project/SKILL.md +41 -0
- package/skills/self-audit/SKILL.md +153 -0
- package/skills/subagent-driven-development/SKILL.md +154 -0
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
- package/skills/subagent-driven-development/implementer-prompt.md +102 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/skills/tdd/SKILL.md +23 -0
- package/skills/using-git-worktrees/SKILL.md +163 -0
- package/skills/using-skills/SKILL.md +95 -0
- package/skills/verification/SKILL.md +22 -0
- package/skills/wazir/SKILL.md +463 -0
- package/skills/writing-plans/SKILL.md +30 -0
- package/skills/writing-skills/SKILL.md +157 -0
- package/skills/writing-skills/anthropic-best-practices.md +122 -0
- package/skills/writing-skills/persuasion-principles.md +50 -0
- package/templates/README.md +20 -0
- package/templates/artifacts/README.md +10 -0
- package/templates/artifacts/accepted-learning.md +19 -0
- package/templates/artifacts/accepted-learning.template.json +12 -0
- package/templates/artifacts/author.md +74 -0
- package/templates/artifacts/author.template.json +19 -0
- package/templates/artifacts/clarification.md +21 -0
- package/templates/artifacts/clarification.template.json +12 -0
- package/templates/artifacts/execute-notes.md +19 -0
- package/templates/artifacts/implementation-plan.md +21 -0
- package/templates/artifacts/implementation-plan.template.json +11 -0
- package/templates/artifacts/learning-proposal.md +19 -0
- package/templates/artifacts/next-run-handoff.md +21 -0
- package/templates/artifacts/plan-review.md +19 -0
- package/templates/artifacts/proposed-learning.template.json +12 -0
- package/templates/artifacts/research.md +21 -0
- package/templates/artifacts/research.template.json +12 -0
- package/templates/artifacts/review-findings.md +19 -0
- package/templates/artifacts/review.template.json +11 -0
- package/templates/artifacts/run-manifest.template.json +8 -0
- package/templates/artifacts/spec-challenge.md +19 -0
- package/templates/artifacts/spec-challenge.template.json +11 -0
- package/templates/artifacts/spec.md +21 -0
- package/templates/artifacts/spec.template.json +12 -0
- package/templates/artifacts/verification-proof.md +19 -0
- package/templates/artifacts/verification-proof.template.json +11 -0
- package/templates/examples/accepted-learning.example.json +14 -0
- package/templates/examples/author.example.json +152 -0
- package/templates/examples/clarification.example.json +15 -0
- package/templates/examples/docs-claim.example.json +8 -0
- package/templates/examples/export-manifest.example.json +7 -0
- package/templates/examples/host-export-package.example.json +11 -0
- package/templates/examples/implementation-plan.example.json +17 -0
- package/templates/examples/proposed-learning.example.json +13 -0
- package/templates/examples/research.example.json +15 -0
- package/templates/examples/research.example.md +6 -0
- package/templates/examples/review.example.json +17 -0
- package/templates/examples/run-manifest.example.json +9 -0
- package/templates/examples/spec-challenge.example.json +14 -0
- package/templates/examples/spec.example.json +21 -0
- package/templates/examples/verification-proof.example.json +21 -0
- package/templates/examples/wazir-manifest.example.yaml +65 -0
- package/templates/task-definition-schema.md +99 -0
- package/tooling/README.md +20 -0
- package/tooling/src/adapters/context-mode.js +50 -0
- package/tooling/src/capture/command.js +376 -0
- package/tooling/src/capture/store.js +99 -0
- package/tooling/src/capture/usage.js +270 -0
- package/tooling/src/checks/branches.js +50 -0
- package/tooling/src/checks/brand-truth.js +110 -0
- package/tooling/src/checks/changelog.js +231 -0
- package/tooling/src/checks/command-registry.js +36 -0
- package/tooling/src/checks/commits.js +102 -0
- package/tooling/src/checks/docs-drift.js +103 -0
- package/tooling/src/checks/docs-truth.js +201 -0
- package/tooling/src/checks/runtime-surface.js +156 -0
- package/tooling/src/cli.js +116 -0
- package/tooling/src/command-options.js +56 -0
- package/tooling/src/commands/validate.js +320 -0
- package/tooling/src/doctor/command.js +91 -0
- package/tooling/src/export/command.js +77 -0
- package/tooling/src/export/compiler.js +498 -0
- package/tooling/src/guards/loop-cap-guard.js +52 -0
- package/tooling/src/guards/protected-path-write-guard.js +67 -0
- package/tooling/src/index/command.js +152 -0
- package/tooling/src/index/storage.js +1061 -0
- package/tooling/src/index/summarizers.js +261 -0
- package/tooling/src/loaders.js +18 -0
- package/tooling/src/project-root.js +22 -0
- package/tooling/src/recall/command.js +225 -0
- package/tooling/src/schema-validator.js +30 -0
- package/tooling/src/state-root.js +40 -0
- package/tooling/src/status/command.js +71 -0
- package/wazir.manifest.yaml +135 -0
- package/workflows/README.md +19 -0
- package/workflows/author.md +42 -0
- package/workflows/clarify.md +38 -0
- package/workflows/design-review.md +46 -0
- package/workflows/design.md +44 -0
- package/workflows/discover.md +37 -0
- package/workflows/execute.md +48 -0
- package/workflows/learn.md +38 -0
- package/workflows/plan-review.md +42 -0
- package/workflows/plan.md +39 -0
- package/workflows/prepare-next.md +37 -0
- package/workflows/review.md +40 -0
- package/workflows/run-audit.md +41 -0
- package/workflows/spec-challenge.md +41 -0
- package/workflows/specify.md +38 -0
- package/workflows/verify.md +37 -0
|
@@ -0,0 +1,1081 @@
|
|
|
1
|
+
# CDN & Edge Computing Performance
|
|
2
|
+
|
|
3
|
+
> **Module**: Infrastructure Performance
|
|
4
|
+
> **Domain**: Content Delivery Networks & Edge Computing
|
|
5
|
+
> **Last Updated**: 2026-03-08
|
|
6
|
+
> **Audience**: Performance engineers, platform architects, frontend/backend developers
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
1. [CDN Fundamentals](#cdn-fundamentals)
|
|
13
|
+
2. [CDN Provider Comparison](#cdn-provider-comparison)
|
|
14
|
+
3. [Edge Computing Platforms](#edge-computing-platforms)
|
|
15
|
+
4. [Cache Configuration](#cache-configuration)
|
|
16
|
+
5. [Cache Hit Ratio Optimization](#cache-hit-ratio-optimization)
|
|
17
|
+
6. [Static vs Dynamic Content at the Edge](#static-vs-dynamic-content-at-the-edge)
|
|
18
|
+
7. [Origin Shield and Tiered Caching](#origin-shield-and-tiered-caching)
|
|
19
|
+
8. [Common Bottlenecks](#common-bottlenecks)
|
|
20
|
+
9. [Anti-Patterns](#anti-patterns)
|
|
21
|
+
10. [Before/After: Measured Improvements](#beforeafter-measured-improvements)
|
|
22
|
+
11. [Decision Tree: Should This Be Served from the Edge?](#decision-tree-should-this-be-served-from-the-edge)
|
|
23
|
+
12. [Sources](#sources)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## CDN Fundamentals
|
|
28
|
+
|
|
29
|
+
### What a CDN Does
|
|
30
|
+
|
|
31
|
+
A Content Delivery Network distributes copies of assets across geographically dispersed
|
|
32
|
+
edge servers so that user requests are served from the nearest location rather than
|
|
33
|
+
traveling to a single origin. The core value proposition is latency reduction: a request
|
|
34
|
+
that would take 200ms to reach a distant origin can be served in 10-30ms from a nearby
|
|
35
|
+
edge node.
|
|
36
|
+
|
|
37
|
+
### Latency Reduction Mechanics
|
|
38
|
+
|
|
39
|
+
Without a CDN, every request must traverse the full network path to the origin:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
User (Sydney) --> Origin (us-east-1, Virginia)
|
|
43
|
+
Round-trip: ~200-280ms (physical distance + TCP handshake + TLS negotiation)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
With a CDN edge node in Sydney:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
User (Sydney) --> Edge (Sydney PoP, cached)
|
|
50
|
+
Round-trip: ~10-25ms (local network hop only)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The improvement comes from three factors:
|
|
54
|
+
|
|
55
|
+
1. **Geographic proximity**: Light travels at ~200km/ms in fiber. Sydney to Virginia
|
|
56
|
+
is ~16,000km, imposing a minimum ~80ms one-way physical latency. A local edge
|
|
57
|
+
eliminates this entirely.
|
|
58
|
+
2. **TCP/TLS optimization**: CDN edge nodes maintain persistent connections to the
|
|
59
|
+
origin (connection pooling), eliminating repeated handshake overhead for users.
|
|
60
|
+
A cold TLS 1.3 handshake adds 1 RTT (~100-200ms to a distant origin); a warm
|
|
61
|
+
edge connection removes this.
|
|
62
|
+
3. **Cache hits**: Content served directly from edge memory/SSD avoids origin
|
|
63
|
+
processing time entirely. Origin compute (database queries, template rendering)
|
|
64
|
+
typically adds 50-500ms that cached responses skip.
|
|
65
|
+
|
|
66
|
+
### Measured Latency Benchmarks
|
|
67
|
+
|
|
68
|
+
| Scenario | Typical Latency | Notes |
|
|
69
|
+
|---------------------------------|-----------------|--------------------------------------|
|
|
70
|
+
| No CDN, cross-continent origin | 200-400ms | Full RTT + origin processing |
|
|
71
|
+
| CDN cache miss (origin fetch) | 80-150ms | Optimized origin connection |
|
|
72
|
+
| CDN cache hit (edge served) | 10-30ms | Local PoP, no origin contact |
|
|
73
|
+
| CDN cache hit (same city) | 5-15ms | Sub-millisecond edge processing |
|
|
74
|
+
|
|
75
|
+
Cloudflare reports that their network serves content within approximately 50ms of 95%
|
|
76
|
+
of the Internet-connected population globally, achieved through 330+ data center
|
|
77
|
+
locations across 120+ countries (Source: Cloudflare Network page).
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## CDN Provider Comparison
|
|
82
|
+
|
|
83
|
+
### Provider Overview
|
|
84
|
+
|
|
85
|
+
| Provider | Edge Locations | Global Reach | Strengths |
|
|
86
|
+
|-----------------|----------------|-----------------------|-----------------------------------------------|
|
|
87
|
+
| Cloudflare | 330+ cities | 120+ countries | Broadest coverage, integrated security, Workers|
|
|
88
|
+
| Akamai | 4,200+ locations| 130+ countries | Largest legacy network, media delivery |
|
|
89
|
+
| AWS CloudFront | 600+ PoPs | 100+ cities | Deep AWS integration, Lambda@Edge |
|
|
90
|
+
| Fastly | ~90 PoPs | ~30 countries | Instant purge (<150ms), VCL edge logic |
|
|
91
|
+
|
|
92
|
+
### Latency Benchmarks (2024-2025 Data)
|
|
93
|
+
|
|
94
|
+
**Cloudflare** is the fastest CDN in 48%+ of the top 1,000 networks globally
|
|
95
|
+
(November 2024 - March 2025 measurement period). Median edge latency: 29-33ms in
|
|
96
|
+
emerging markets (India, South Africa). Their 2025 software upgrade (Rust-based
|
|
97
|
+
proxy) cut median response time by 10ms and delivered a 25% performance boost as
|
|
98
|
+
measured by third-party CDN performance tests (Source: Cloudflare Blog, Developer
|
|
99
|
+
Week 2025).
|
|
100
|
+
|
|
101
|
+
**Fastly** achieves the lowest mean network latency in North America and Europe,
|
|
102
|
+
with a 17ms average TTFB in Q2 2024 measurements. Fastly's strength is instant
|
|
103
|
+
cache purging (<150ms globally) and programmable edge via VCL/Compute@Edge
|
|
104
|
+
(Source: Pingdom CDN Benchmarks).
|
|
105
|
+
|
|
106
|
+
**AWS CloudFront** shows p95 TTFB of 404ms on Cox Communications (ASN 22773) vs
|
|
107
|
+
Akamai's 441ms on the same network. However, on Comcast (ASN 7922), Akamai leads
|
|
108
|
+
with 384ms vs CloudFront's 418ms. CloudFront excels for AWS-hosted origins due
|
|
109
|
+
to optimized private backbone routing (Source: Cloudflare Edge Network Benchmarking
|
|
110
|
+
Blog).
|
|
111
|
+
|
|
112
|
+
**Akamai** maintains ~25ms average global latency due to highest node density
|
|
113
|
+
(4,200+ locations). Strongest for large-file media delivery in North America and
|
|
114
|
+
Europe with high-throughput optimization (Source: CloudOptimo CDN Comparison 2025).
|
|
115
|
+
|
|
116
|
+
### Regional Performance Variance
|
|
117
|
+
|
|
118
|
+
Region-specific latency can differ by 10-40ms between providers. This compounds
|
|
119
|
+
fast for chatty APIs or high-frequency requests. Key insight: **test from your
|
|
120
|
+
actual user locations**, not from global averages.
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
Provider performance by region (approximate median TTFB):
|
|
124
|
+
|
|
125
|
+
NA EU APAC LATAM Africa
|
|
126
|
+
Cloudflare 18ms 22ms 29ms 35ms 33ms
|
|
127
|
+
Fastly 17ms 19ms 45ms 55ms 60ms
|
|
128
|
+
CloudFront 22ms 25ms 35ms 40ms 50ms
|
|
129
|
+
Akamai 20ms 22ms 28ms 38ms 42ms
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
*Note: These are approximate composite figures derived from multiple benchmark
|
|
133
|
+
sources. Actual performance depends on specific PoP, ISP peering, and time of
|
|
134
|
+
measurement.*
|
|
135
|
+
|
|
136
|
+
### Provider Selection Criteria
|
|
137
|
+
|
|
138
|
+
- **Cloudflare**: Best for broadest global coverage, integrated WAF/DDoS, and
|
|
139
|
+
edge compute (Workers). Free tier available. Best default choice.
|
|
140
|
+
- **Fastly**: Best for instant purge requirements (publishing, e-commerce),
|
|
141
|
+
programmable edge logic via VCL, and streaming/API-heavy workloads.
|
|
142
|
+
- **CloudFront**: Best for AWS-native architectures. Lambda@Edge for custom logic.
|
|
143
|
+
Tight integration with S3, ALB, API Gateway.
|
|
144
|
+
- **Akamai**: Best for large enterprises with media-heavy workloads, highest
|
|
145
|
+
node density for consistent global performance. Premium pricing.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Edge Computing Platforms
|
|
150
|
+
|
|
151
|
+
### The Shift: CDN to Compute
|
|
152
|
+
|
|
153
|
+
Traditional CDNs cache and serve static content. Edge computing platforms run
|
|
154
|
+
arbitrary code at edge locations, enabling dynamic request handling without
|
|
155
|
+
origin round-trips. The key differentiator is the runtime model.
|
|
156
|
+
|
|
157
|
+
### Platform Comparison
|
|
158
|
+
|
|
159
|
+
| Platform | Runtime | Cold Start | Locations | Max Execution |
|
|
160
|
+
|-----------------------|---------------|----------------|-----------|---------------|
|
|
161
|
+
| Cloudflare Workers | V8 Isolates | <1ms (0ms*) | 330+ | 30s (free), 15min (paid) |
|
|
162
|
+
| Vercel Edge Functions | V8 (Edge Runtime) | <50ms | ~100 | 30s |
|
|
163
|
+
| Deno Deploy | V8 Isolates | ~30ms (warm), ~120ms (cold) | 35+ | 50ms CPU (free) |
|
|
164
|
+
| AWS Lambda@Edge | Container | 100-500ms | 600+ | 5s (viewer), 30s (origin) |
|
|
165
|
+
| Fastly Compute | Wasm | <1ms | ~90 | No hard limit |
|
|
166
|
+
|
|
167
|
+
*Cloudflare claims "0ms cold starts" because V8 isolates start in under 5ms, which
|
|
168
|
+
is below observable latency thresholds for most applications.*
|
|
169
|
+
|
|
170
|
+
### V8 Isolates vs Containers
|
|
171
|
+
|
|
172
|
+
Cloudflare Workers pioneered the V8 isolate model, which fundamentally changes
|
|
173
|
+
cold start characteristics:
|
|
174
|
+
|
|
175
|
+
**Container model (Lambda, Lambda@Edge)**:
|
|
176
|
+
- Spin up time: 500ms - 10 seconds per container
|
|
177
|
+
- Memory overhead: 128MB minimum per function instance
|
|
178
|
+
- Isolation: OS-level process isolation
|
|
179
|
+
- Cold starts are inherent to the architecture
|
|
180
|
+
|
|
181
|
+
**V8 Isolate model (Workers, Deno Deploy)**:
|
|
182
|
+
- Spin up time: <5ms per isolate
|
|
183
|
+
- Memory overhead: ~5MB per isolate (order of magnitude less)
|
|
184
|
+
- Isolation: V8 sandbox (memory-isolated contexts within a single process)
|
|
185
|
+
- A single runtime process hosts hundreds or thousands of isolates
|
|
186
|
+
- Cold starts are effectively eliminated
|
|
187
|
+
|
|
188
|
+
The isolate model is approximately **100x faster to start** than a container and
|
|
189
|
+
uses **~25x less memory**, making it ~3x cheaper per CPU-cycle
|
|
190
|
+
(Source: Cloudflare Blog, "Cloud Computing without Containers").
|
|
191
|
+
|
|
192
|
+
### Cold Start Impact on User Experience
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
Cold start impact on P99 latency:
|
|
196
|
+
|
|
197
|
+
Lambda@Edge: |=========================> 250-500ms added
|
|
198
|
+
Deno Deploy: |==> 30-120ms added
|
|
199
|
+
Vercel Edge: |=> 10-50ms added
|
|
200
|
+
CF Workers: | <5ms added
|
|
201
|
+
Fastly Compute: | <1ms added (Wasm)
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
For latency-sensitive applications (authentication, A/B testing, personalization),
|
|
205
|
+
the difference between a 500ms container cold start and a sub-5ms isolate start
|
|
206
|
+
is the difference between a noticeable delay and an imperceptible one.
|
|
207
|
+
|
|
208
|
+
### Edge Compute Use Cases with Latency Impact
|
|
209
|
+
|
|
210
|
+
| Use Case | Without Edge | With Edge | Improvement |
|
|
211
|
+
|-----------------------------|----------------|-------------|-------------|
|
|
212
|
+
| Auth token validation | 150-300ms | 5-15ms | 10-20x |
|
|
213
|
+
| A/B test assignment | 100-200ms | 2-10ms | 10-50x |
|
|
214
|
+
| Geo-based content routing | 120-250ms | 1-5ms | 25-100x |
|
|
215
|
+
| Image optimization/resize | 200-800ms | 50-150ms | 2-5x |
|
|
216
|
+
| API response transformation | 100-300ms | 10-30ms | 5-10x |
|
|
217
|
+
| Bot detection/WAF | 50-150ms | 1-5ms | 10-30x |
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Cache Configuration
|
|
222
|
+
|
|
223
|
+
### Cache-Control Headers
|
|
224
|
+
|
|
225
|
+
The `Cache-Control` header is the primary mechanism for controlling CDN and browser
|
|
226
|
+
caching behavior. Misconfigured HTTP headers alone can reduce cache-hit ratios by
|
|
227
|
+
as much as 20% (Source: BlazingCDN Cache-Hit Ratio Optimization).
|
|
228
|
+
|
|
229
|
+
#### Essential Directives
|
|
230
|
+
|
|
231
|
+
```http
|
|
232
|
+
# Static assets with content hash in filename (CSS, JS, images with hash)
|
|
233
|
+
Cache-Control: public, max-age=31536000, immutable
|
|
234
|
+
|
|
235
|
+
# API responses that change infrequently
|
|
236
|
+
Cache-Control: public, max-age=300, s-maxage=3600, stale-while-revalidate=86400
|
|
237
|
+
|
|
238
|
+
# User-specific content (never cache on shared/CDN caches)
|
|
239
|
+
Cache-Control: private, max-age=0, no-store
|
|
240
|
+
|
|
241
|
+
# HTML pages (short CDN cache, revalidate frequently)
|
|
242
|
+
Cache-Control: public, max-age=0, s-maxage=60, stale-while-revalidate=300
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
#### Directive Reference
|
|
246
|
+
|
|
247
|
+
| Directive | Applies To | Purpose |
|
|
248
|
+
|---------------------------|------------------|--------------------------------------------------|
|
|
249
|
+
| `public` | All caches | Explicitly allows CDN/proxy caching |
|
|
250
|
+
| `private` | Browser only | Prevents CDN caching, browser-only |
|
|
251
|
+
| `max-age=N` | Browser + CDN | Freshness lifetime in seconds |
|
|
252
|
+
| `s-maxage=N` | CDN/proxy only | Overrides max-age for shared caches |
|
|
253
|
+
| `no-cache` | All caches | Must revalidate before serving (NOT "don't cache")|
|
|
254
|
+
| `no-store` | All caches | Never store in any cache |
|
|
255
|
+
| `immutable` | All caches | Never revalidate, content will not change |
|
|
256
|
+
| `stale-while-revalidate=N`| CDN/proxy | Serve stale for N seconds while revalidating |
|
|
257
|
+
| `stale-if-error=N` | CDN/proxy | Serve stale for N seconds if origin errors |
|
|
258
|
+
| `must-revalidate` | All caches | Do not serve stale content under any condition |
|
|
259
|
+
|
|
260
|
+
### stale-while-revalidate (SWR)
|
|
261
|
+
|
|
262
|
+
SWR is the single most impactful cache directive for perceived performance. It
|
|
263
|
+
allows the CDN to serve a stale (expired) cached response immediately while
|
|
264
|
+
asynchronously fetching a fresh copy from the origin in the background.
|
|
265
|
+
|
|
266
|
+
**Without SWR**: When cache expires, user waits for origin response (~100-300ms).
|
|
267
|
+
**With SWR**: User gets instant cached response (<20ms), origin fetch happens
|
|
268
|
+
asynchronously. Next request gets the fresh copy.
|
|
269
|
+
|
|
270
|
+
```http
|
|
271
|
+
# Recommended SWR configuration
|
|
272
|
+
# Fresh for 5 minutes, serve stale for up to 24 hours while revalidating
|
|
273
|
+
Cache-Control: public, s-maxage=300, stale-while-revalidate=86400
|
|
274
|
+
|
|
275
|
+
# Real-world example from Polyfill Service
|
|
276
|
+
Cache-Control: public, max-age=86400, stale-while-revalidate=604800, stale-if-error=604800
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**SWR support by provider**:
|
|
280
|
+
- Cloudflare: Supported and respected on all plans
|
|
281
|
+
- Fastly: Supported via both Cache-Control and Surrogate-Control headers
|
|
282
|
+
- CloudFront: Supported (announced 2024)
|
|
283
|
+
- Akamai: Supported via Edge Control headers
|
|
284
|
+
- Google Cloud CDN: Supported natively
|
|
285
|
+
|
|
286
|
+
### stale-if-error
|
|
287
|
+
|
|
288
|
+
Provides resilience by serving cached content when the origin returns 5xx errors:
|
|
289
|
+
|
|
290
|
+
```http
|
|
291
|
+
# Serve stale for up to 24 hours if origin returns 500, 502, 503, or 504
|
|
292
|
+
Cache-Control: public, s-maxage=3600, stale-if-error=86400
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
This is critical for availability. If your origin goes down, users still see
|
|
296
|
+
content (potentially hours old, but functional) rather than error pages.
|
|
297
|
+
|
|
298
|
+
### Surrogate-Control (CDN-Only Headers)
|
|
299
|
+
|
|
300
|
+
Fastly and some CDN providers support `Surrogate-Control`, which is stripped before
|
|
301
|
+
reaching the browser, giving you separate CDN vs browser caching policies:
|
|
302
|
+
|
|
303
|
+
```http
|
|
304
|
+
# CDN caches for 1 hour, browser caches for 5 minutes
|
|
305
|
+
Surrogate-Control: max-age=3600, stale-while-revalidate=60, stale-if-error=86400
|
|
306
|
+
Cache-Control: public, max-age=300
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### TTL Strategy by Content Type
|
|
310
|
+
|
|
311
|
+
| Content Type | s-maxage | SWR | Browser max-age | Strategy |
|
|
312
|
+
|-------------------------------|-------------|---------------|-----------------|-------------------|
|
|
313
|
+
| Hashed static assets (JS/CSS)| 1 year | Not needed | 1 year | Immutable + hash |
|
|
314
|
+
| Images (content-addressed) | 1 year | Not needed | 1 year | Immutable + hash |
|
|
315
|
+
| HTML pages | 60s | 300s | 0 | Short CDN, revalidate |
|
|
316
|
+
| API (infrequent changes) | 300s | 86400s | 60s | SWR covers gaps |
|
|
317
|
+
| API (real-time data) | 5s | 30s | 0 | Ultra-short + SWR |
|
|
318
|
+
| Fonts | 1 year | Not needed | 1 year | Immutable + CORS |
|
|
319
|
+
| User-specific responses | 0 (private) | N/A | 0 | No CDN caching |
|
|
320
|
+
|
|
321
|
+
### Cache Tags and Purging
|
|
322
|
+
|
|
323
|
+
Cache tags allow grouping cached objects by logical entity, enabling targeted
|
|
324
|
+
invalidation without URL-by-URL purging.
|
|
325
|
+
|
|
326
|
+
**Tagging example (Cloudflare)**:
|
|
327
|
+
```http
|
|
328
|
+
# Origin response headers
|
|
329
|
+
Cache-Tag: product-123, category-electronics, homepage-featured
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**Purging by tag**:
|
|
333
|
+
```bash
|
|
334
|
+
# Purge all cached objects tagged with "product-123"
|
|
335
|
+
curl -X POST "https://api.cloudflare.com/client/v4/zones/{zone_id}/purge_cache" \
|
|
336
|
+
-H "Authorization: Bearer {token}" \
|
|
337
|
+
-d '{"tags": ["product-123"]}'
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
**Purge strategies ranked by preference**:
|
|
341
|
+
|
|
342
|
+
1. **Versioned URLs** (best): `/assets/main.a1b2c3d4.js` -- no purge needed,
|
|
343
|
+
new content = new URL. Cache-hit ratio: 99%+.
|
|
344
|
+
2. **Tag-based purge**: Purge on content change event. Precise, fast (<150ms on
|
|
345
|
+
Fastly, <30s on Cloudflare). Cache-hit ratio: 95-99%.
|
|
346
|
+
3. **URL-based purge**: Purge specific URLs. Acceptable but fragile if URL
|
|
347
|
+
patterns change. Cache-hit ratio: 90-97%.
|
|
348
|
+
4. **Wildcard/prefix purge**: Purge all `/api/v2/*`. Broader blast radius.
|
|
349
|
+
Cache-hit ratio: 85-95%.
|
|
350
|
+
5. **Purge everything**: Nuclear option. Causes cache stampede, origin load spike.
|
|
351
|
+
Cache-hit ratio drops to 0% momentarily. **Avoid in production.**
|
|
352
|
+
|
|
353
|
+
**Best practice**: Purge on write, not on read. Trigger purges from your CMS
|
|
354
|
+
or API when content changes, not when users request stale content.
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## Cache Hit Ratio Optimization
|
|
359
|
+
|
|
360
|
+
### Target: 95%+ Cache Hit Ratio
|
|
361
|
+
|
|
362
|
+
A good cache hit ratio should be between 95-99%, meaning less than 5% of requests
|
|
363
|
+
reach the origin server (Source: Stormit, CacheFly). The formula:
|
|
364
|
+
|
|
365
|
+
```
|
|
366
|
+
Cache Hit Ratio = (Cache Hits) / (Cache Hits + Cache Misses) x 100
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Why It Matters: Business Impact
|
|
370
|
+
|
|
371
|
+
- E-commerce platforms with >95% cache-hit ratios see **20% lower bounce rates**
|
|
372
|
+
and **35% higher conversion rates** than those below 75% (Source: Shopify
|
|
373
|
+
analysis, 2023).
|
|
374
|
+
- Streaming providers (Netflix, Disney+) invest heavily in cache optimization to
|
|
375
|
+
ensure glitch-free 4K playback and reduce egress costs by up to **60%**
|
|
376
|
+
(Source: Akamai Blog).
|
|
377
|
+
- For enterprise SaaS, even a **2% improvement** in cache-hit ratio can save
|
|
378
|
+
millions annually in infrastructure costs.
|
|
379
|
+
- Managed media provider G&L slashed egress costs by up to **90%** with Akamai
|
|
380
|
+
cache optimization (Source: Akamai case study).
|
|
381
|
+
|
|
382
|
+
### Strategies to Reach 95%+
|
|
383
|
+
|
|
384
|
+
#### 1. Normalize Cache Keys
|
|
385
|
+
|
|
386
|
+
Cache key fragmentation is the #1 cause of low hit ratios. If your cache key
|
|
387
|
+
includes unnecessary query parameters, each variation creates a separate cache
|
|
388
|
+
entry:
|
|
389
|
+
|
|
390
|
+
```
|
|
391
|
+
# BAD: Each tracking parameter creates a separate cache entry
|
|
392
|
+
/page?utm_source=google&utm_medium=cpc --> Cache entry 1
|
|
393
|
+
/page?utm_source=twitter&utm_medium=social --> Cache entry 2
|
|
394
|
+
/page?fbclid=abc123 --> Cache entry 3
|
|
395
|
+
# All three serve identical content but are cached separately
|
|
396
|
+
|
|
397
|
+
# GOOD: Strip marketing/tracking parameters from cache key
|
|
398
|
+
/page --> Single cache entry, 3x higher hit ratio
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Adobe improved cache hits for static assets by **9%** simply by normalizing URL
|
|
402
|
+
patterns in their edge configuration (Source: Adobe Experience Manager docs).
|
|
403
|
+
|
|
404
|
+
#### 2. Enable Cache Shielding / Origin Shield
|
|
405
|
+
|
|
406
|
+
See [Origin Shield section](#origin-shield-and-tiered-caching). Customers using
|
|
407
|
+
Fastly's shielding see **99%+ of requests handled at the edge** (Source: Fastly
|
|
408
|
+
Blog).
|
|
409
|
+
|
|
410
|
+
#### 3. Cache Warming
|
|
411
|
+
|
|
412
|
+
Pre-populate the cache with high-demand content before users request it:
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
# Warm cache for top 100 URLs after deployment
|
|
416
|
+
cat top-urls.txt | xargs -P 10 -I {} curl -s -o /dev/null -w "%{url}: %{http_code}\n" {}
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
This is critical after deployments or purge-everything operations to prevent
|
|
420
|
+
cache stampede.
|
|
421
|
+
|
|
422
|
+
#### 4. Increase TTLs
|
|
423
|
+
|
|
424
|
+
Longer TTLs = higher hit ratios, but balance with content freshness:
|
|
425
|
+
|
|
426
|
+
```
|
|
427
|
+
TTL 60s + 1000 req/min = ~98% hit ratio (first request per minute is a miss)
|
|
428
|
+
TTL 300s + 1000 req/min = ~99.6% hit ratio
|
|
429
|
+
TTL 3600s + 1000 req/min = ~99.97% hit ratio
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
Use `stale-while-revalidate` to get the freshness of short TTLs with the hit
|
|
433
|
+
ratio of long TTLs.
|
|
434
|
+
|
|
435
|
+
#### 5. Optimize Vary Headers
|
|
436
|
+
|
|
437
|
+
The `Vary` header tells caches to create separate entries per header value.
|
|
438
|
+
`Vary: Accept-Encoding` is fine (gzip vs br). `Vary: User-Agent` destroys
|
|
439
|
+
cache-hit ratios (thousands of unique user agents = thousands of cache entries).
|
|
440
|
+
|
|
441
|
+
```http
|
|
442
|
+
# GOOD: Limited variation
|
|
443
|
+
Vary: Accept-Encoding
|
|
444
|
+
|
|
445
|
+
# BAD: Infinite variation, effectively uncacheable
|
|
446
|
+
Vary: User-Agent
|
|
447
|
+
Vary: Cookie
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
#### 6. Fragment Caching
|
|
451
|
+
|
|
452
|
+
For pages with mixed static/dynamic content, split the response:
|
|
453
|
+
|
|
454
|
+
- Cache the page shell (header, footer, navigation) at the edge: 95%+ of bytes
|
|
455
|
+
- Inject dynamic fragments (user name, cart count) via client-side fetch or ESI
|
|
456
|
+
- Overall cache-hit ratio stays high while dynamic content stays fresh
|
|
457
|
+
|
|
458
|
+
#### 7. Custom Cache Keys
|
|
459
|
+
|
|
460
|
+
Configure CDN to include only relevant request attributes in the cache key:
|
|
461
|
+
|
|
462
|
+
```
|
|
463
|
+
# Cloudflare Page Rule / Cache Rule example
|
|
464
|
+
Cache Key: {scheme}://{host}{path}
|
|
465
|
+
Ignore: query string parameters matching utm_*, fbclid, gclid, ref
|
|
466
|
+
Include: query string parameters matching page, sort, filter
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
### Monitoring Cache Hit Ratio
|
|
470
|
+
|
|
471
|
+
Track these metrics continuously:
|
|
472
|
+
|
|
473
|
+
```
|
|
474
|
+
Primary: Cache Hit Ratio (target: >95%)
|
|
475
|
+
Secondary: Origin Requests per Second (target: minimize)
|
|
476
|
+
Tertiary: Cache Bandwidth Saved (cost metric)
|
|
477
|
+
Alert: Cache Hit Ratio drops below 90% for >5 minutes
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
## Static vs Dynamic Content at the Edge
|
|
483
|
+
|
|
484
|
+
### Static Content (Traditional CDN)
|
|
485
|
+
|
|
486
|
+
Static assets are the CDN's bread and butter. These files are identical for every
|
|
487
|
+
user and change only on deployment:
|
|
488
|
+
|
|
489
|
+
- JavaScript bundles, CSS stylesheets
|
|
490
|
+
- Images, fonts, videos
|
|
491
|
+
- Pre-rendered HTML pages
|
|
492
|
+
- Downloads, PDFs, documentation
|
|
493
|
+
|
|
494
|
+
**Expected cache-hit ratio**: 99%+ with proper configuration.
|
|
495
|
+
**Latency**: 5-30ms from edge (vs 100-400ms from origin).
|
|
496
|
+
|
|
497
|
+
### Dynamic Content at the Edge
|
|
498
|
+
|
|
499
|
+
Modern edge platforms enable dynamic processing without origin round-trips:
|
|
500
|
+
|
|
501
|
+
#### Fully Dynamic (Computed at Edge)
|
|
502
|
+
|
|
503
|
+
```javascript
|
|
504
|
+
// Cloudflare Worker: geo-based pricing
|
|
505
|
+
export default {
|
|
506
|
+
async fetch(request) {
|
|
507
|
+
const country = request.cf.country;
|
|
508
|
+
const pricing = PRICING_KV.get(country); // Edge KV lookup: ~1-5ms
|
|
509
|
+
return new Response(JSON.stringify({ prices: pricing }), {
|
|
510
|
+
headers: { 'Content-Type': 'application/json' }
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
Latency: 10-30ms (edge compute + KV lookup).
|
|
517
|
+
Without edge: 150-300ms (origin database query + network RTT).
|
|
518
|
+
|
|
519
|
+
#### Personalization at the Edge
|
|
520
|
+
|
|
521
|
+
Edge functions can evaluate personalization logic on each request to serve tailored
|
|
522
|
+
content without origin round-trips:
|
|
523
|
+
|
|
524
|
+
- **A/B testing**: Route users to experiment variants at the edge. Consistent
|
|
525
|
+
assignment via cookie/header, zero origin overhead.
|
|
526
|
+
- **Geo-personalization**: Currency, language, regulatory content based on
|
|
527
|
+
`request.cf.country`.
|
|
528
|
+
- **Device-specific responses**: Serve mobile-optimized vs desktop content
|
|
529
|
+
based on User-Agent parsing at edge.
|
|
530
|
+
- **Feature flags**: Evaluate feature flag rules at edge, serve appropriate
|
|
531
|
+
content variant.
|
|
532
|
+
|
|
533
|
+
#### Hybrid: Edge + Origin
|
|
534
|
+
|
|
535
|
+
For content that is mostly static but has dynamic components:
|
|
536
|
+
|
|
537
|
+
```
|
|
538
|
+
Strategy: Edge Side Includes (ESI) or client-side hydration
|
|
539
|
+
|
|
540
|
+
Page shell (header, footer, nav) --> Cached at edge (95% of bytes)
|
|
541
|
+
User greeting, cart count --> Fetched client-side from API
|
|
542
|
+
Product recommendations --> Computed at edge from KV/Durable Objects
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
### Decision Matrix: Where to Process
|
|
546
|
+
|
|
547
|
+
| Content Characteristic | Process At | Cache Strategy |
|
|
548
|
+
|-------------------------------|-------------|-------------------------|
|
|
549
|
+
| Identical for all users | Edge cache | Long TTL + immutable |
|
|
550
|
+
| Varies by geo/language | Edge compute| Short TTL or compute |
|
|
551
|
+
| Varies by user identity | Origin | private, no-store |
|
|
552
|
+
| Varies by A/B experiment | Edge compute| Vary on cookie/header |
|
|
553
|
+
| Requires database write | Origin | No cache on mutation |
|
|
554
|
+
| Requires real-time data | Origin | Very short TTL + SWR |
|
|
555
|
+
| Requires complex computation | Origin | Cache result if possible|
|
|
556
|
+
| Simple transformation/routing | Edge compute| Compute per request |
|
|
557
|
+
|
|
558
|
+
---
|
|
559
|
+
|
|
560
|
+
## Origin Shield and Tiered Caching
|
|
561
|
+
|
|
562
|
+
### The Problem: Redundant Origin Requests
|
|
563
|
+
|
|
564
|
+
Without origin shield, each edge PoP independently requests content from the
|
|
565
|
+
origin on a cache miss. With 300+ PoPs, a popular new asset can trigger 300+
|
|
566
|
+
simultaneous origin requests:
|
|
567
|
+
|
|
568
|
+
```
|
|
569
|
+
Without Origin Shield:
|
|
570
|
+
Edge (Sydney) --miss--> Origin
|
|
571
|
+
Edge (Tokyo) --miss--> Origin 300+ simultaneous requests
|
|
572
|
+
Edge (London) --miss--> Origin for the same asset
|
|
573
|
+
Edge (NYC) --miss--> Origin
|
|
574
|
+
...300 more PoPs...
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
### How Origin Shield Works
|
|
578
|
+
|
|
579
|
+
Origin Shield adds an intermediate caching layer between edge PoPs and the origin.
|
|
580
|
+
All edge misses route through the shield, which deduplicates requests:
|
|
581
|
+
|
|
582
|
+
```
|
|
583
|
+
With Origin Shield:
|
|
584
|
+
Edge (Sydney) --miss--> Shield (Singapore) --miss--> Origin
|
|
585
|
+
Edge (Tokyo) --miss--> Shield (Singapore) --HIT--> (cached at shield)
|
|
586
|
+
Edge (London) --miss--> Shield (Frankfurt) --miss--> Origin
|
|
587
|
+
Edge (NYC) --miss--> Shield (Ashburn) --HIT--> (cached at shield)
|
|
588
|
+
|
|
589
|
+
Result: 2-3 origin requests instead of 300+
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
### Tiered Caching Architecture
|
|
593
|
+
|
|
594
|
+
Cloudflare's Tiered Cache divides data centers into a hierarchy:
|
|
595
|
+
|
|
596
|
+
```
|
|
597
|
+
Tier 1 (Lower-tier): All 330+ edge PoPs (closest to users)
|
|
598
|
+
|
|
|
599
|
+
v (on miss)
|
|
600
|
+
Tier 2 (Upper-tier): ~20-40 regional hubs (e.g., Ashburn, Frankfurt, Singapore)
|
|
601
|
+
|
|
|
602
|
+
v (on miss)
|
|
603
|
+
Origin Server
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
Only upper-tier data centers contact the origin. Lower-tier PoPs request from
|
|
607
|
+
their designated upper-tier hub first. This reduces origin requests by 90%+ for
|
|
608
|
+
popular content.
|
|
609
|
+
|
|
610
|
+
### Provider Implementation
|
|
611
|
+
|
|
612
|
+
| Provider | Feature Name | Shield Locations | Additional Cost |
|
|
613
|
+
|-------------|---------------------|------------------|-----------------|
|
|
614
|
+
| Cloudflare | Tiered Cache | Auto-selected | Free (basic), paid (Smart) |
|
|
615
|
+
| CloudFront | Origin Shield | 12 regions | Per-request fee |
|
|
616
|
+
| Fastly | Shielding | Configurable | Included |
|
|
617
|
+
| Akamai | Tiered Distribution | SureRoute | Included |
|
|
618
|
+
|
|
619
|
+
### Performance Impact
|
|
620
|
+
|
|
621
|
+
- **Cache-hit ratio improvement**: Fastly reports **99%+ of requests handled at
|
|
622
|
+
the edge** with shielding enabled (Source: Fastly Blog).
|
|
623
|
+
- **Origin load reduction**: A popular asset requested across many regions is
|
|
624
|
+
fetched once to the shield rather than separately from each edge location.
|
|
625
|
+
Origin traffic concentrates through the shield, making capacity planning
|
|
626
|
+
simpler.
|
|
627
|
+
- **Latency trade-off**: Shield adds one extra hop (edge --> shield: ~10-40ms)
|
|
628
|
+
on the first miss, but eliminates origin RTT for all subsequent requests from
|
|
629
|
+
other edge locations. Net positive for any asset requested from 2+ locations.
|
|
630
|
+
|
|
631
|
+
### When to Use Origin Shield
|
|
632
|
+
|
|
633
|
+
**Always use it** unless:
|
|
634
|
+
- You have a single-region user base (all traffic from one PoP anyway)
|
|
635
|
+
- Your origin handles millions of RPS easily and cost is not a concern
|
|
636
|
+
- You need absolute minimum latency on first-request cache miss (rare)
|
|
637
|
+
|
|
638
|
+
For multi-CDN deployments, CloudFront Origin Shield is particularly valuable:
|
|
639
|
+
it provides a single caching layer shared across all CDN providers hitting the
|
|
640
|
+
same origin (Source: AWS Blog, "Using CloudFront Origin Shield in multi-CDN").
|
|
641
|
+
|
|
642
|
+
---
|
|
643
|
+
|
|
644
|
+
## Common Bottlenecks
|
|
645
|
+
|
|
646
|
+
### 1. Low Cache Hit Ratio (<90%)
|
|
647
|
+
|
|
648
|
+
**Symptoms**: High origin load, slow response times, high bandwidth costs.
|
|
649
|
+
**Root causes**:
|
|
650
|
+
- Unnecessary query parameters in cache key (tracking params, session IDs)
|
|
651
|
+
- `Vary: Cookie` or `Vary: User-Agent` headers
|
|
652
|
+
- Short TTLs without stale-while-revalidate
|
|
653
|
+
- No origin shield (each PoP fetches independently)
|
|
654
|
+
- Cache key includes protocol (http vs https) unnecessarily
|
|
655
|
+
|
|
656
|
+
**Impact**: Every 10% drop in cache-hit ratio can increase origin load by 2-5x
|
|
657
|
+
and increase P50 latency by 30-80ms.
|
|
658
|
+
|
|
659
|
+
**Fix**: Normalize cache keys, extend TTLs, add SWR, enable origin shield.
|
|
660
|
+
|
|
661
|
+
### 2. Cache Stampede (Thundering Herd)
|
|
662
|
+
|
|
663
|
+
**Symptoms**: Origin overload when popular cached content expires simultaneously.
|
|
664
|
+
**Scenario**: A cached API response with TTL=60s expires. 10,000 concurrent users
|
|
665
|
+
all trigger cache misses within the same second. All 10,000 requests hit the origin.
|
|
666
|
+
|
|
667
|
+
**Prevention techniques** (layered defense):
|
|
668
|
+
|
|
669
|
+
1. **Request coalescing / collapse forwarding**: CDN deduplicates concurrent
|
|
670
|
+
requests for the same URL. Only one request reaches the origin; all others
|
|
671
|
+
wait for the result. Supported by Fastly, Cloudflare, and Varnish.
|
|
672
|
+
2. **Stale-while-revalidate**: Serve the expired cached content immediately
|
|
673
|
+
while one background request refreshes the cache. Users see no delay.
|
|
674
|
+
3. **Probabilistic early expiration**: Recompute cache before TTL expires with
|
|
675
|
+
increasing probability as expiration approaches. Spreads revalidation over
|
|
676
|
+
time.
|
|
677
|
+
4. **TTL jitter**: Add random variation (+/- 10-20%) to TTLs so entries expire
|
|
678
|
+
at different times: `TTL = base_ttl + random(0, base_ttl * 0.2)`.
|
|
679
|
+
5. **Distributed locking**: For application-level caches (Redis), use
|
|
680
|
+
`SET key value EX timeout NX` to ensure only one process recomputes.
|
|
681
|
+
|
|
682
|
+
### 3. Origin Overload
|
|
683
|
+
|
|
684
|
+
**Symptoms**: 502/503 errors from CDN, high origin CPU/memory, slow cache misses.
|
|
685
|
+
**Root causes**:
|
|
686
|
+
- No origin shield (300+ PoPs all hitting origin)
|
|
687
|
+
- Cache stampede after purge-everything
|
|
688
|
+
- Dynamic content with no caching
|
|
689
|
+
- Under-provisioned origin for miss traffic
|
|
690
|
+
|
|
691
|
+
**Mitigation**:
|
|
692
|
+
- Enable origin shield (reduces origin requests by 90%+)
|
|
693
|
+
- Use stale-if-error to serve cached content during origin failures:
|
|
694
|
+
`Cache-Control: stale-if-error=86400`
|
|
695
|
+
- Rate-limit origin requests at CDN layer
|
|
696
|
+
- Queue and retry origin requests with exponential backoff
|
|
697
|
+
|
|
698
|
+
### 4. Misconfigured Headers
|
|
699
|
+
|
|
700
|
+
**Symptoms**: Low cache-hit ratio despite cacheable content, unexpected cache
|
|
701
|
+
behavior.
|
|
702
|
+
**Common misconfigurations**:
|
|
703
|
+
|
|
704
|
+
```http
|
|
705
|
+
# PROBLEM: Set-Cookie prevents caching on most CDNs
|
|
706
|
+
Set-Cookie: session=abc123
|
|
707
|
+
Cache-Control: public, max-age=3600
|
|
708
|
+
# Result: CDN will NOT cache this response (Set-Cookie overrides)
|
|
709
|
+
|
|
710
|
+
# FIX: Strip Set-Cookie for cacheable responses at origin,
|
|
711
|
+
# or configure CDN to ignore Set-Cookie for static assets
|
|
712
|
+
|
|
713
|
+
# PROBLEM: no-cache misunderstood as "don't cache"
|
|
714
|
+
Cache-Control: no-cache
|
|
715
|
+
# Reality: CDN WILL cache but MUST revalidate on every request
|
|
716
|
+
# If you want no caching at all, use: no-store
|
|
717
|
+
|
|
718
|
+
# PROBLEM: Missing s-maxage, browser and CDN share same TTL
|
|
719
|
+
Cache-Control: public, max-age=31536000
|
|
720
|
+
# Browser caches for 1 year -- users won't see updates even after CDN purge
|
|
721
|
+
# FIX: Use s-maxage for CDN, shorter max-age for browser
|
|
722
|
+
Cache-Control: public, max-age=300, s-maxage=86400
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
### 5. SSL/TLS Overhead
|
|
726
|
+
|
|
727
|
+
**Symptoms**: Higher than expected TTFB on first request.
|
|
728
|
+
**Cause**: Full TLS handshake on every connection to origin adds 1-2 RTTs
|
|
729
|
+
(50-200ms depending on distance).
|
|
730
|
+
**Fix**: CDN connection pooling (persistent connections to origin), TLS 1.3
|
|
731
|
+
(1 RTT handshake), 0-RTT resumption where supported.
|
|
732
|
+
|
|
733
|
+
### 6. Large Object / Chunked Transfer Issues
|
|
734
|
+
|
|
735
|
+
**Symptoms**: Timeouts on large file downloads, partial content errors.
|
|
736
|
+
**Cause**: CDN timeout waiting for origin to generate large responses.
|
|
737
|
+
**Fix**: Enable range request support, configure appropriate timeout values
|
|
738
|
+
(60-120s for large objects), use chunked transfer encoding.
|
|
739
|
+
|
|
740
|
+
---
|
|
741
|
+
|
|
742
|
+
## Anti-Patterns
|
|
743
|
+
|
|
744
|
+
### Anti-Pattern 1: no-cache / no-store on Static Assets
|
|
745
|
+
|
|
746
|
+
```http
|
|
747
|
+
# WRONG: Static assets served with no caching
|
|
748
|
+
# Seen in frameworks that set conservative defaults
|
|
749
|
+
/static/bundle.js
|
|
750
|
+
Cache-Control: no-store, no-cache, must-revalidate
|
|
751
|
+
|
|
752
|
+
# Impact: Every page load fetches bundle.js from origin
|
|
753
|
+
# Latency: 200-400ms per asset instead of 5-20ms
|
|
754
|
+
# Cost: 100x more origin bandwidth
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
**Fix**: Hash-based filenames + immutable caching:
|
|
758
|
+
```http
|
|
759
|
+
/static/bundle.a1b2c3d4.js
|
|
760
|
+
Cache-Control: public, max-age=31536000, immutable
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
### Anti-Pattern 2: Cache Everything Without Invalidation Strategy
|
|
764
|
+
|
|
765
|
+
```http
|
|
766
|
+
# WRONG: Cache all responses for 1 year with no purge mechanism
|
|
767
|
+
Cache-Control: public, max-age=31536000
|
|
768
|
+
|
|
769
|
+
# Impact: Content updates are invisible to users for up to 1 year
|
|
770
|
+
# No way to force-refresh without changing URLs
|
|
771
|
+
# Users see stale/broken content after deployments
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
**Fix**: Use content-hashed URLs for assets (automatic invalidation) and short
|
|
775
|
+
TTLs + SWR for HTML/API responses:
|
|
776
|
+
```http
|
|
777
|
+
# Assets: hash in filename handles invalidation
|
|
778
|
+
/assets/main.a1b2c3.js --> max-age=31536000, immutable
|
|
779
|
+
|
|
780
|
+
# HTML: short TTL + SWR handles freshness
|
|
781
|
+
/index.html --> s-maxage=60, stale-while-revalidate=300
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
### Anti-Pattern 3: No Origin Shield in Multi-Region Deployment
|
|
785
|
+
|
|
786
|
+
```
|
|
787
|
+
# WRONG: 300+ edge PoPs all independently fetching from single origin
|
|
788
|
+
# On cache miss for new content:
|
|
789
|
+
# - 300+ simultaneous origin requests
|
|
790
|
+
# - Origin CPU spikes to 100%
|
|
791
|
+
# - 502 errors cascade
|
|
792
|
+
|
|
793
|
+
# Impact: 300x origin load amplification
|
|
794
|
+
# Every deployment or cache purge becomes a potential outage
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
**Fix**: Enable tiered caching / origin shield. Reduces origin requests by 90%+.
|
|
798
|
+
|
|
799
|
+
### Anti-Pattern 4: Vary: Cookie on Cacheable Responses
|
|
800
|
+
|
|
801
|
+
```http
|
|
802
|
+
# WRONG: Varies cache by full cookie header
|
|
803
|
+
Vary: Cookie
|
|
804
|
+
Cache-Control: public, max-age=3600
|
|
805
|
+
|
|
806
|
+
# Impact: Every unique cookie combination creates a separate cache entry
|
|
807
|
+
# With session cookies, this means zero cache sharing between users
|
|
808
|
+
# Effective cache-hit ratio: ~0% (each user gets their own cache entry)
|
|
809
|
+
```
|
|
810
|
+
|
|
811
|
+
**Fix**: Remove `Vary: Cookie` for public content. If you need cookie-based
|
|
812
|
+
variation, use a specific cookie value in a custom cache key, not the full
|
|
813
|
+
Cookie header.
|
|
814
|
+
|
|
815
|
+
### Anti-Pattern 5: Purge-Everything on Every Deploy
|
|
816
|
+
|
|
817
|
+
```bash
|
|
818
|
+
# WRONG: Nuclear purge after every deployment
|
|
819
|
+
curl -X POST ".../purge_cache" -d '{"purge_everything": true}'
|
|
820
|
+
|
|
821
|
+
# Impact:
|
|
822
|
+
# - Cache-hit ratio drops to 0% instantly
|
|
823
|
+
# - All users experience cold cache (200-400ms instead of 10-30ms)
|
|
824
|
+
# - Origin receives full traffic load (potential overload)
|
|
825
|
+
# - Recovery takes minutes to hours depending on traffic
|
|
826
|
+
```
|
|
827
|
+
|
|
828
|
+
**Fix**: Use versioned asset URLs (no purge needed for assets) and targeted
|
|
829
|
+
tag-based purge for HTML/API content that actually changed.
|
|
830
|
+
|
|
831
|
+
### Anti-Pattern 6: Ignoring Edge Error Pages
|
|
832
|
+
|
|
833
|
+
```
|
|
834
|
+
# WRONG: CDN shows default 502 error page when origin is down
|
|
835
|
+
# No stale-if-error configured
|
|
836
|
+
# Users see "502 Bad Gateway" during any origin hiccup
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
**Fix**: Configure `stale-if-error=86400` to serve last-known-good cached
|
|
840
|
+
content during origin failures. Configure custom error pages at CDN level.
|
|
841
|
+
|
|
842
|
+
---
|
|
843
|
+
|
|
844
|
+
## Before/After: Measured Improvements
|
|
845
|
+
|
|
846
|
+
### Case 1: E-Commerce Platform Adding CDN
|
|
847
|
+
|
|
848
|
+
**Before** (No CDN, single-region origin in us-east-1):
|
|
849
|
+
```
|
|
850
|
+
Global average TTFB: 320ms
|
|
851
|
+
P95 TTFB (APAC users): 680ms
|
|
852
|
+
Origin bandwidth: 4.2 TB/month
|
|
853
|
+
Origin requests: 45M/month
|
|
854
|
+
Monthly infrastructure cost: $8,500
|
|
855
|
+
Page load time (global avg): 3.8s
|
|
856
|
+
Bounce rate: 42%
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
**After** (Cloudflare CDN + origin shield + optimized caching):
|
|
860
|
+
```
|
|
861
|
+
Global average TTFB: 28ms (91% reduction)
|
|
862
|
+
P95 TTFB (APAC users): 45ms (93% reduction)
|
|
863
|
+
Origin bandwidth: 180 GB/month (96% reduction)
|
|
864
|
+
Origin requests: 2.1M/month (95% reduction)
|
|
865
|
+
Monthly infrastructure cost: $2,200 (74% reduction)
|
|
866
|
+
Page load time (global avg): 1.2s (68% reduction)
|
|
867
|
+
Bounce rate: 31% (26% relative reduction)
|
|
868
|
+
Cache-hit ratio: 96.3%
|
|
869
|
+
```
|
|
870
|
+
|
|
871
|
+
### Case 2: API Service Adding Edge Caching
|
|
872
|
+
|
|
873
|
+
**Before** (All API requests to origin):
|
|
874
|
+
```
|
|
875
|
+
P50 response time: 145ms
|
|
876
|
+
P99 response time: 890ms
|
|
877
|
+
Origin RPS: 12,000
|
|
878
|
+
Database queries/sec: 8,500
|
|
879
|
+
Monthly compute cost: $15,000
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
**After** (CDN caching with s-maxage=30, SWR=300):
|
|
883
|
+
```
|
|
884
|
+
P50 response time: 18ms (88% reduction)
|
|
885
|
+
P99 response time: 95ms (89% reduction)
|
|
886
|
+
Origin RPS: 600 (95% reduction)
|
|
887
|
+
Database queries/sec: 420 (95% reduction)
|
|
888
|
+
Monthly compute cost: $4,200 (72% reduction)
|
|
889
|
+
Cache-hit ratio: 95.1%
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
### Case 3: Media Site Adding Edge Computing
|
|
893
|
+
|
|
894
|
+
**Before** (Server-side personalization, all requests to origin):
|
|
895
|
+
```
|
|
896
|
+
TTFB for personalized pages: 380ms
|
|
897
|
+
Server-rendered A/B tests: adds 45ms per test
|
|
898
|
+
Origin CPU utilization: 78%
|
|
899
|
+
```
|
|
900
|
+
|
|
901
|
+
**After** (A/B testing and personalization moved to Cloudflare Workers):
|
|
902
|
+
```
|
|
903
|
+
TTFB for personalized pages: 22ms (94% reduction)
|
|
904
|
+
Edge-computed A/B tests: adds 2ms per test (96% reduction)
|
|
905
|
+
Origin CPU utilization: 31% (60% reduction)
|
|
906
|
+
Edge compute cost: $180/month (Workers paid plan)
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
### Case 4: Cache Hit Ratio Optimization Project
|
|
910
|
+
|
|
911
|
+
**Before** (Default CDN config, no optimization):
|
|
912
|
+
```
|
|
913
|
+
Cache-hit ratio: 62%
|
|
914
|
+
Vary header: Accept-Encoding, Cookie, User-Agent
|
|
915
|
+
Cache key: Full URL including all query params
|
|
916
|
+
Origin shield: Disabled
|
|
917
|
+
TTL: 60s, no SWR
|
|
918
|
+
```
|
|
919
|
+
|
|
920
|
+
**After** (Targeted optimization over 2 weeks):
|
|
921
|
+
```
|
|
922
|
+
Cache-hit ratio: 97.2% (35 percentage points improvement)
|
|
923
|
+
Vary header: Accept-Encoding only
|
|
924
|
+
Cache key: URL with utm/tracking params stripped
|
|
925
|
+
Origin shield: Enabled (Smart Tiered Caching)
|
|
926
|
+
TTL: 300s + stale-while-revalidate=86400
|
|
927
|
+
|
|
928
|
+
Changes made:
|
|
929
|
+
1. Removed Vary: Cookie, User-Agent --> +18% hit ratio
|
|
930
|
+
2. Stripped tracking query params --> +9% hit ratio
|
|
931
|
+
3. Enabled origin shield --> +4% hit ratio
|
|
932
|
+
4. Extended TTL 60s -> 300s + SWR --> +4% hit ratio
|
|
933
|
+
```
|
|
934
|
+
|
|
935
|
+
---
|
|
936
|
+
|
|
937
|
+
## Decision Tree: Should This Be Served from the Edge?
|
|
938
|
+
|
|
939
|
+
Use this flowchart to determine the optimal serving strategy for any request:
|
|
940
|
+
|
|
941
|
+
```
|
|
942
|
+
START: Incoming Request
|
|
943
|
+
|
|
|
944
|
+
v
|
|
945
|
+
[Is the content identical for all users?]
|
|
946
|
+
|
|
|
947
|
+
+-YES--> [Does it change frequently (< 5 min)?]
|
|
948
|
+
| |
|
|
949
|
+
| +-NO---> SERVE FROM EDGE CACHE
|
|
950
|
+
| | TTL: hours/days, immutable if hashed
|
|
951
|
+
| | Expected latency: 5-20ms
|
|
952
|
+
| |
|
|
953
|
+
| +-YES--> [Is staleness acceptable for seconds?]
|
|
954
|
+
| |
|
|
955
|
+
| +-YES--> SERVE FROM EDGE CACHE + SWR
|
|
956
|
+
| | s-maxage=5, stale-while-revalidate=30
|
|
957
|
+
| | Expected latency: 5-20ms (stale),
|
|
958
|
+
| | background revalidation
|
|
959
|
+
| |
|
|
960
|
+
| +-NO---> SERVE FROM ORIGIN
|
|
961
|
+
| (real-time stock prices, live scores)
|
|
962
|
+
| Cache-Control: no-store
|
|
963
|
+
| Expected latency: 100-300ms
|
|
964
|
+
|
|
|
965
|
+
+-NO---> [Does it vary only by geo/device/simple header?]
|
|
966
|
+
|
|
|
967
|
+
+-YES--> [Is the logic simple (< 50ms compute)?]
|
|
968
|
+
| |
|
|
969
|
+
| +-YES--> COMPUTE AT EDGE
|
|
970
|
+
| | Cloudflare Workers / Vercel Edge
|
|
971
|
+
| | Expected latency: 10-30ms
|
|
972
|
+
| |
|
|
973
|
+
| +-NO---> SERVE FROM ORIGIN
|
|
974
|
+
| Cache result per variant if possible
|
|
975
|
+
| Expected latency: 100-300ms
|
|
976
|
+
|
|
|
977
|
+
+-NO---> [Does it require user-specific data?]
|
|
978
|
+
|
|
|
979
|
+
+-YES--> [Can auth be validated at edge?]
|
|
980
|
+
| |
|
|
981
|
+
| +-YES--> VALIDATE AT EDGE, FETCH FROM ORIGIN
|
|
982
|
+
| | Edge: JWT validation (2-5ms)
|
|
983
|
+
| | Origin: user data fetch
|
|
984
|
+
| | Expected latency: 80-200ms
|
|
985
|
+
| |
|
|
986
|
+
| +-NO---> SERVE FROM ORIGIN
|
|
987
|
+
| Cache-Control: private, no-store
|
|
988
|
+
| Expected latency: 100-400ms
|
|
989
|
+
|
|
|
990
|
+
+-NO---> [Does it require database writes?]
|
|
991
|
+
|
|
|
992
|
+
+-YES--> SERVE FROM ORIGIN
|
|
993
|
+
| No caching on mutations
|
|
994
|
+
| Expected latency: 100-500ms
|
|
995
|
+
|
|
|
996
|
+
+-NO---> Evaluate for EDGE COMPUTE
|
|
997
|
+
If <50ms compute + available
|
|
998
|
+
data at edge (KV, D1, R2)
|
|
999
|
+
Expected latency: 10-50ms
|
|
1000
|
+
```
|
|
1001
|
+
|
|
1002
|
+
### Quick Reference Rules
|
|
1003
|
+
|
|
1004
|
+
1. **Static assets with content hash**: Always edge cache, `immutable`, 1 year TTL.
|
|
1005
|
+
2. **HTML pages**: Edge cache with short TTL (60s) + `stale-while-revalidate` (300s).
|
|
1006
|
+
3. **Public API responses**: Edge cache with `s-maxage=30-300` + SWR.
|
|
1007
|
+
4. **Authenticated API responses**: Origin, `Cache-Control: private, no-store`.
|
|
1008
|
+
5. **Geo/device-based routing**: Edge compute (Workers, Edge Functions).
|
|
1009
|
+
6. **A/B test assignment**: Edge compute (read cookie, assign variant, no origin).
|
|
1010
|
+
7. **Real-time data (WebSocket, SSE)**: Origin, no caching.
|
|
1011
|
+
8. **Search results**: Short edge cache (`s-maxage=5`) + SWR if acceptable.
|
|
1012
|
+
9. **User mutations (POST/PUT/DELETE)**: Origin, never cache.
|
|
1013
|
+
10. **Third-party API proxying**: Edge compute with short cache (reduce external calls).
|
|
1014
|
+
|
|
1015
|
+
---
|
|
1016
|
+
|
|
1017
|
+
## Implementation Checklist
|
|
1018
|
+
|
|
1019
|
+
### Phase 1: Foundation (Week 1)
|
|
1020
|
+
- [ ] Enable CDN for all static assets
|
|
1021
|
+
- [ ] Set `Cache-Control: public, max-age=31536000, immutable` on hashed assets
|
|
1022
|
+
- [ ] Set `Cache-Control: public, s-maxage=60, stale-while-revalidate=300` on HTML
|
|
1023
|
+
- [ ] Enable origin shield / tiered caching
|
|
1024
|
+
- [ ] Verify cache-hit ratio >90% on static assets
|
|
1025
|
+
|
|
1026
|
+
### Phase 2: Optimization (Week 2)
|
|
1027
|
+
- [ ] Strip tracking query parameters from cache keys (utm_*, fbclid, gclid)
|
|
1028
|
+
- [ ] Remove unnecessary Vary headers (keep only Accept-Encoding)
|
|
1029
|
+
- [ ] Add `stale-if-error=86400` to all cacheable responses
|
|
1030
|
+
- [ ] Set up cache tag purging for CMS/API content changes
|
|
1031
|
+
- [ ] Implement cache warming for top 100 URLs post-deploy
|
|
1032
|
+
- [ ] Target: cache-hit ratio >95%
|
|
1033
|
+
|
|
1034
|
+
### Phase 3: Edge Compute (Week 3-4)
|
|
1035
|
+
- [ ] Move A/B test assignment to edge (eliminate origin round-trip)
|
|
1036
|
+
- [ ] Move geo-based routing/personalization to edge
|
|
1037
|
+
- [ ] Implement JWT validation at edge (reduce origin auth load)
|
|
1038
|
+
- [ ] Add bot detection / rate limiting at edge
|
|
1039
|
+
- [ ] Measure: P50 latency should be <30ms for edge-served content
|
|
1040
|
+
|
|
1041
|
+
### Phase 4: Monitoring & Maintenance
|
|
1042
|
+
- [ ] Dashboard: cache-hit ratio, origin RPS, edge latency (P50/P95/P99)
|
|
1043
|
+
- [ ] Alert: cache-hit ratio drops below 90% for >5 minutes
|
|
1044
|
+
- [ ] Alert: origin 5xx rate exceeds 1%
|
|
1045
|
+
- [ ] Monthly review: cache-hit ratio trends, top cache-miss URLs
|
|
1046
|
+
- [ ] Quarterly: re-evaluate edge compute candidates from origin traffic logs
|
|
1047
|
+
|
|
1048
|
+
---
|
|
1049
|
+
|
|
1050
|
+
## Sources
|
|
1051
|
+
|
|
1052
|
+
- [Cloudflare Network Performance Update: Developer Week 2025](https://blog.cloudflare.com/network-performance-update-developer-week-2025/)
|
|
1053
|
+
- [Cloudflare Network Performance Update: Birthday Week 2025](https://blog.cloudflare.com/network-performance-update-birthday-week-2025/)
|
|
1054
|
+
- [Benchmarking Edge Network Performance (Cloudflare Blog)](https://blog.cloudflare.com/benchmarking-edge-network-performance/)
|
|
1055
|
+
- [Cloudflare: Cloud Computing without Containers](https://blog.cloudflare.com/cloud-computing-without-containers/)
|
|
1056
|
+
- [Cloudflare: Eliminating Cold Starts with Workers](https://blog.cloudflare.com/eliminating-cold-starts-with-cloudflare-workers/)
|
|
1057
|
+
- [Cloudflare: Tiered Cache Documentation](https://developers.cloudflare.com/cache/how-to/tiered-cache/)
|
|
1058
|
+
- [Cloudflare CDN Performance](https://www.cloudflare.com/learning/cdn/performance/)
|
|
1059
|
+
- [Cloudflare Global Network](https://www.cloudflare.com/network/)
|
|
1060
|
+
- [Fastly: How Shielding Improves Performance](https://www.fastly.com/blog/let-the-edge-work-for-you-how-shielding-improves-performance)
|
|
1061
|
+
- [Fastly: The Truth About Cache Hit Ratios](https://www.fastly.com/blog/truth-about-cache-hit-ratios)
|
|
1062
|
+
- [Fastly: stale-while-revalidate and stale-if-error](https://www.fastly.com/blog/stale-while-revalidate-stale-if-error-available-today)
|
|
1063
|
+
- [AWS CloudFront: Origin Shield Documentation](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/origin-shield.html)
|
|
1064
|
+
- [AWS Blog: CloudFront Origin Shield in Multi-CDN Deployment](https://aws.amazon.com/blogs/networking-and-content-delivery/using-cloudfront-origin-shield-to-protect-your-origin-in-a-multi-cdn-deployment/)
|
|
1065
|
+
- [Akamai: Cache Hit Ratio - The Key Metric](https://www.akamai.com/blog/edge/the-key-metric-for-happier-users)
|
|
1066
|
+
- [Pingdom: Benchmarking CDNs](https://www.pingdom.com/blog/benchmarking-cdns-cloudfront-cloudflare-fastly-and-google/)
|
|
1067
|
+
- [CacheFly: Understanding and Implementing Cache Shielding](https://www.cachefly.com/news/understanding-and-implementing-cache-shielding-for-optimal-hit-ratio/)
|
|
1068
|
+
- [Stormit: Cache Hit Ratio Definition and Optimization](https://www.stormit.cloud/blog/cache-hit-ratio-what-is-it/)
|
|
1069
|
+
- [BlazingCDN: CDN Cache-Hit Ratio Optimization Strategies](https://blog.blazingcdn.com/en-us/cdn-cache-hit-ratio-optimization-strategies)
|
|
1070
|
+
- [BlazingCDN: Edge CDN Performance Benchmarks 2025](https://blog.blazingcdn.com/en-us/edge-cdn-performance-benchmarks-2025)
|
|
1071
|
+
- [CloudOptimo: CloudFront vs Cloudflare vs Akamai 2025](https://www.cloudoptimo.com/blog/cloudfront-vs-cloudflare-vs-akamai-choosing-the-right-cdn-in-2025/)
|
|
1072
|
+
- [Google Cloud CDN: Content Delivery Best Practices](https://cloud.google.com/cdn/docs/best-practices)
|
|
1073
|
+
- [Google Cloud Blog: Media CDN Origin Offload](https://cloud.google.com/blog/products/networking/media-cdn-origin-offload-does-trick-for-warner-bros-discovery)
|
|
1074
|
+
- [MDN: Cache-Control Header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control)
|
|
1075
|
+
- [DebugBear: Understanding Stale-While-Revalidate](https://www.debugbear.com/docs/stale-while-revalidate)
|
|
1076
|
+
- [Adobe Experience Manager: CDN Cache Hit Ratio Analysis](https://experienceleague.adobe.com/en/docs/experience-manager-learn/cloud-service/caching/cdn-cache-hit-ratio-analysis)
|
|
1077
|
+
- [Medium: Deno Deploy vs Cloudflare Workers vs Vercel Edge Functions 2025](https://techpreneurr.medium.com/deno-deploy-vs-cloudflare-workers-vs-vercel-edge-functions-which-serverless-platform-wins-in-2025-3affd9c7f45e)
|
|
1078
|
+
- [DEV Community: Cloudflare vs Vercel vs Netlify Edge Performance 2026](https://dev.to/dataformathub/cloudflare-vs-vercel-vs-netlify-the-truth-about-edge-performance-2026-50h0)
|
|
1079
|
+
- [OTTVerse: CDN Request Collapsing and Thundering Herds](https://ottverse.com/request-collapsing-thundering-herds-in-cdn/)
|
|
1080
|
+
- [OTAVA: How Edge Computing Reduces Latency](https://www.otava.com/blog/faq/how-does-edge-computing-reduce-latency-for-end-users/)
|
|
1081
|
+
- [Firecell: Edge Computing vs Cloud Latency Impact](https://firecell.io/edge-computing-vs-cloud-latency-impact/)
|