CloudFront Cache Troubleshooter
Activation
Activate this skill when the user reports a CloudFront caching issue.
Trigger phrases: "CloudFront cache miss every request", "CloudFront not
caching", "CloudFront stale content", "CloudFront content not updating",
"CloudFront cache hit ratio low", "CloudFront origin load high",
"CloudFront 403 from cache", "CloudFront 404 from edge", "CloudFront
different content per user", "CloudFront cache key variation", "CloudFront
cache policy misconfigured", "x-cache Miss from cloudfront",
"x-edge-result-type Miss", "troubleshoot CloudFront caching".
Mindset
One-line takeaway: every CloudFront caching problem is a mismatch
between what the cache key captures, what the origin allows to be cached,
and what the cache policy TTL instructs. The diagnostic walk identifies
which of these three is broken.
Three facts make CloudFront cache diagnosis different:
- CloudFront caches by cache key, not by URL alone. The cache key =
URL path + query strings + headers + cookies (per the cache policy).
Including
User-Agent fragments the cache so badly that hit ratio
drops to near zero.
- Origin
Cache-Control headers dominate unless the cache policy
overrides them. If the origin sends Cache-Control: no-store,
CloudFront will not cache regardless of the policy TTL.
x-edge-result-type in access logs is the ground truth. Values:
Hit, Miss, RefreshHit, RefreshMiss, Error, LimitExceeded,
CapacityExceeded, Denied. Miss every time means cache key or
origin headers prevent caching.
Expert heuristic
Five senior-CDN-engineer heuristics (edge-only hit ratio, Lambda@Edge header rewrites, Origin Shield break-even, compression size limits, Functions vs Lambda@Edge cache timing) moved verbatim to references/advanced-patterns.md.
Load on demand when the symptom contradicts the cache policy analysis.
Quick reference — symptom to cache issue
| Observed signal |
Cache issue |
First probe |
x-edge-result-type: Miss on every request |
ORIGIN_NO_CACHE / ORIGIN_NO_STORE / CACHE_POLICY_TOO_NARROW |
curl -I to origin for Cache-Control; cache policy TTL |
| Content hours/days old; origin updated |
STALE_NO_INVALIDATION / TTL_TOO_LONG |
Origin max-age vs behavior TTL; invalidation history |
| Same URL, different content per user |
CACHE_KEY_BLOAT |
Cache policy headers/cookies/query strings |
| 403 / 404 from CloudFront; origin returns 200 |
WAF_BLOCK / LAMBDA_EDGE_MUTATION |
WAF web ACL; Lambda@Edge logs |
| Hit ratio dropping; origin load rising |
CACHE_KEY_BLOAT / TTL_TOO_SHORT |
Cache policy DefaultTTL; cache key values |
RefreshHit frequent; origin gets If-Modified-Since |
TTL_EXPIRED / STALE-REVALIDATE |
Origin max-age vs behavior MinTTL |
Process — Diagnostic decision tree (apply in order)
Step 0: Capture the cache signal
| Signal |
Source |
Why required |
| Distribution ID or domain |
User-provided or list-distributions |
All get-distribution-config calls need this |
| Symptom (miss vs stale vs variation) |
User report + curl -I |
Drives the symptom category |
| x-edge-result-type / x-cache |
Access logs (S3) or curl -I |
Ground truth for edge behavior |
If distribution/domain unknown:
list-distributions / get-distribution-config discovery commands moved verbatim to references/diagnostic-commands.md.
Run them when the distribution ID or domain is unknown.
Step 1: Identify the symptom category
| Category |
Signature |
Diagnostic step |
| A. CACHE_MISS_ALWAYS |
Miss on every request; x-cache: Miss from cloudfront |
Step 2 |
| B. STALE_CONTENT |
Content old; origin updated; no invalidation sent |
Step 3 |
| C. CACHE_KEY_VARIATION |
Same URL, different content per user; hit ratio near zero |
Step 4 |
| D. ERROR_FROM_CACHE |
403/404 from CloudFront; origin returns 200; x-edge-result-type: Error |
Step 5 |
| E. LOW_HIT_RATIO |
Hit ratio dropping; origin load rising; mix of Hit and Miss |
Step 6 |
Priority if multiple match: CACHE_MISS_ALWAYS > ERROR_FROM_CACHE >
CACHE_KEY_VARIATION > STALE_CONTENT > LOW_HIT_RATIO.
Step 2: CACHE_MISS_ALWAYS diagnostic
Every request is a Miss. Cause: origin sends no-cache/no-store, cache
policy TTL is 0, CachingDisabled attached, or response not cacheable.
Diagnostic walk:
- Check origin
Cache-Control (#1 cause). curl -I directly to origin:
# Direct to origin (bypass CloudFront):
curl -sI https://origin.example.com/path/to/content | grep -iE 'cache-control|expires|pragma|set-cookie'
# Via CloudFront:
curl -sI https://d123.cloudfront.net/path/to/content | grep -iE 'x-cache|age|cache-control'
| Origin header |
Effect |
Fix |
Cache-Control: no-store |
Never caches |
Change to public, max-age=3600 |
Cache-Control: no-cache |
Revalidates every request (RefreshMiss) |
Change to public, max-age=3600 |
Cache-Control: max-age=0 |
Same as no-cache |
Raise to desired TTL |
Cache-Control: private |
Not cached (browser-only) |
Change to public |
Pragma: no-cache |
Legacy HTTP/1.0 no-cache |
Remove |
Set-Cookie in response |
May skip caching if cookie not in policy |
Add cookie to policy or remove Set-Cookie |
- Check cache policy TTL:
MinTTL: 0, DefaultTTL: 0, MaxTTL: 0 disables
caching. Managed CachingDisabled (ID 4135ea2d-6df8-44a3-9df3-4b5a84be39ad)
explicitly sets all TTLs to 0.
aws cloudfront get-cache-policy --id <cache-policy-id> \
--query 'CachePolicy.CachePolicyConfig.{minTTL:MinTTL,defaultTTL:DefaultTTL,maxTTL:MaxTTL,headers:ParametersInCacheKeyAndForwardedToOrigin.HeadersConfig.HeaderBehavior}' \
--output json
- Check if origin returns cacheable status codes. CloudFront caches
200, 206, 301, 302, 304, 404 (optionally).
Common fixes:
- Origin sends
no-store: update origin to Cache-Control: public, max-age=3600.
For S3: aws s3api put-object with --cache-control.
- Cache policy TTL is 0: set
DefaultTTL: 3600 or use managed
CachingOptimized (658327ea-f89d-4fab-a63d-7e88639e58f6).
Set-Cookie preventing caching: add cookie to policy or remove from response.
Step 3: STALE_CONTENT diagnostic
Content served from cache but old — origin updated but CloudFront serves
cached version. Cause: TTL not expired (expected without invalidation), no
invalidation sent, or cache behavior overrides origin with longer TTL.
Diagnostic walk:
- Determine if invalidation is needed. CloudFront serves cached content
until TTL expires OR invalidation clears it. No invalidation after origin
update = stale until TTL expires. This is expected, not a bug.
- Compare origin
max-age vs cache behavior TTL. If origin sends
max-age=86400 but operator expects minutes, TTL is too long.
- Check
OriginCacheControlHeaders handling. If set to respect,
CloudFront uses origin's max-age. If override, uses policy DefaultTTL.
- Check invalidation history. If invalidation sent but stale persists,
it may be for wrong paths or still in progress.
# List recent invalidations.
aws cloudfront list-invalidations --distribution-id <id> \
--query 'InvalidationList.Items[*].{id:Id,status:Status,paths:InvalidationBatch.Paths.Items,created:CreateTime}' \
--output json
# Check the Age header (how long object has been cached):
curl -sI https://d123.cloudfront.net/path | grep -iE 'x-cache|age|cache-control'
| Sub-symptom |
Root cause |
Fix |
| No invalidation sent, TTL not expired |
Expected behaviour |
Send invalidation OR wait for TTL |
| Invalidation sent but still stale |
Wrong paths or in progress |
Verify get-invalidation status; paths match |
Origin max-age=86400 but expects 5-min |
TTL too long |
Lower origin max-age or policy MaxTTL |
| Stale after deployment |
No invalidation in CI/CD |
Add invalidation step to deploy pipeline |
Common fixes:
- Send invalidation:
aws cloudfront create-invalidation --distribution-id <id> --paths "/updated/*".
Prefer specific paths over /* to avoid spiking origin load.
- Add invalidation to CI/CD pipeline.
- For frequently-updated content, set shorter TTL (
max-age=300).
Step 4: CACHE_KEY_VARIATION diagnostic
Same URL but different content per user; hit ratio near zero. Cause: cache
key bloat — too many headers, cookies, or query strings creating unique
entries.
Cache key formula: cache key = URL path + query strings (per policy) + headers (per policy) + cookies (per policy). Any value included creates a
distinct entry per unique combination.
Diagnostic walk:
- Read cache policy
ParametersInCacheKeyAndForwardedToOrigin:
aws cloudfront get-cache-policy --id <cache-policy-id> \
--query 'CachePolicy.CachePolicyConfig.ParametersInCacheKeyAndForwardedToOrigin' \
--output json
| Cache policy setting |
Effect |
Recommendation |
HeadersConfig.HeaderBehavior: none |
No headers in key |
Default; use unless response varies |
QueryStringsConfig.QueryStringBehavior: all |
ALL query strings in key |
Only if every param affects response |
CookiesConfig.CookieBehavior: all |
ALL cookies in key |
Almost never correct — fragments cache |
CookiesConfig.CookieBehavior: whitelist + specific |
Listed cookies only |
Only cookies that affect response |
- Check for fragmenting headers:
User-Agent (thousands of values),
Authorization (unique per user), X-Forwarded-For (unique per client).
Do NOT include these in the cache key.
- Check
Accept-Encoding — required in cache key for compressed content.
Managed AllViewerExceptReservedHeader includes it by default.
- Check access logs: if every request is
Miss for same URL, cache key
varies per request. Compare cs-cookie and cs-accept-encoding fields.
See references/worked-examples.md for the managed policy reference table
and cache key normalization details.
Common fixes:
- Remove
User-Agent from headers whitelist. Use none or only headers
that affect the response.
- Switch
CookiesConfig.CookieBehavior from all to whitelist with
only necessary cookies.
- For static assets, use managed
CachingOptimized.
- For dynamic APIs, use
CachingDisabled.
Step 5: ERROR_FROM_CACHE diagnostic
CloudFront returns 403 or 404; origin returns 200. Cause: WAF blocking,
Lambda@Edge modifying response, cached transient error, or wrong origin.
Diagnostic walk:
- Check for WAF:
aws cloudfront get-distribution-config --id <id> --query 'DistributionConfig.WebACLId'. Blocked requests return 403
with x-amzn-waf-action: BLOCK.
- Check Lambda@Edge on behavior: a function on
viewer-response or
origin-response can modify status code/headers/body.
- Check origin directly:
curl -I bypassing CloudFront. If origin
returns 200 but CloudFront returns 403/404, issue is in CloudFront layer.
- Check for cached 404: CloudFront caches 404 if policy allows it
(
errorResponseCachingBehavior). A transient 404 can persist after
origin recovers.
- Check cache behavior target origin: if pointing to deleted/wrong
origin, origin returns 404.
# Check WAF rules if attached:
aws wafv2 get-web-acl --scope CLOUDFRONT --id <web-acl-id> \
--query 'WebACL.Rules[*].{name:Name,action:Action,priority:Priority}' --output json
# Check Lambda@Edge functions:
aws cloudfront get-distribution-config --id <id> \
--query 'DistributionConfig.DefaultCacheBehavior.LambdaFunctionAssociations.Items[*].{type:EventType,arn:LambdaFunctionARN}' \
--output json
| Sub-symptom |
Root cause |
Fix |
403 with x-amzn-waf-action: BLOCK |
WAF blocking |
Adjust WAF rules; add allowlist |
| 403 without WAF header |
Lambda@Edge returning 403 |
Check function logs; curl origin directly |
| 404 persists after origin recovers |
Cached transient 404 |
Invalidate; lower 404 cache TTL |
| 404 on specific path |
Wrong TargetOriginId |
Update behavior's TargetOriginId |
See references/worked-examples.md for Lambda@Edge response modification
edge cases.
Step 6: LOW_HIT_RATIO diagnostic
Hit ratio dropping; origin load rising; mix of Hit and Miss. Cause: cache
key bloat, TTL too short, origin sending no-cache on some responses, or
long-tail content (more unique URLs).
Diagnostic walk:
- Check
CacheHitRate metric:
aws cloudwatch get-metric-statistics --namespace AWS/CloudFront \
--metric-name CacheHitRate \
--dimensions Name=DistributionId,Value=<id> \
--start-time $(date -u -d '24 hours ago' +%Y-%m-%dT%H:%M:%SZ) \
--end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) \
--period 3600 --statistics Average --output json
- Analyze access logs for the Miss pattern — group by path, query
string, headers.
- Check long tail: if content catalog grew, each URL is a miss on
first request (expected). Fix: pre-warming or accept lower ratio.
- Check inconsistent origin headers: some responses with
no-cache,
others with max-age=3600 = inconsistent ratio.
| Sub-symptom |
Root cause |
Fix |
| Drop after traffic increase |
Long-tail content |
Pre-warm; accept lower ratio |
| Low for specific path |
Cache key bloat on that behavior |
Narrow the cache policy |
Low with frequent RefreshHit |
TTL expired; frequent revalidation |
Raise TTL |
| Low after deploy |
Invalidation cleared cache |
Expected; ratio recovers |
Common fixes:
- Separate static and dynamic content into different cache behaviors.
- Raise TTL for content that changes infrequently. S3 immutable objects:
max-age=31536000 (1 year).
- Use Origin Shield as second-tier cache.
- Pre-warm cache after deploys.
Step 7: Map to root-cause catalog
| # |
Root cause |
Category |
Fix pattern |
| 1 |
Origin sends Cache-Control: no-store or no-cache |
CACHE_MISS_ALWAYS (ORIGIN_NO_CACHE) |
Update origin to public, max-age=<TTL> |
| 2 |
Cache policy TTL is 0 or CachingDisabled |
CACHE_MISS_ALWAYS (CACHE_POLICY_TOO_NARROW) |
Switch to CachingOptimized or set DefaultTTL > 0 |
| 3 |
No invalidation after origin update |
STALE_CONTENT (STALE_NO_INVALIDATION) |
Send invalidation; add to CI/CD |
| 4 |
TTL too long for frequently-updated content |
STALE_CONTENT (TTL_TOO_LONG) |
Lower max-age or policy MaxTTL |
| 5 |
User-Agent or Authorization in cache key |
CACHE_KEY_VARIATION (CACHE_KEY_BLOAT) |
Remove from cache policy headers |
| 6 |
All cookies in cache key |
CACHE_KEY_VARIATION (CACHE_KEY_BLOAT) |
Switch to whitelist with necessary cookies |
| 7 |
WAF blocking requests |
ERROR_FROM_CACHE (WAF_BLOCK) |
Adjust WAF rules; add allowlist |
| 8 |
Lambda@Edge modifying response |
ERROR_FROM_CACHE (LAMBDA_EDGE_MUTATION) |
Fix function; remove from behavior |
| 9 |
Cached transient 404 |
ERROR_FROM_CACHE (ORIGIN_ERROR) |
Invalidate; lower 404 cache TTL |
| 10 |
Accept-Encoding not in cache key for compressed content |
CACHE_KEY_VARIATION (COMPRESSION_CACHE_KEY) |
Add Accept-Encoding to policy |
Step 8: Verify the fix
- Origin header changes: verify with
curl -I, request via CloudFront
twice — second should show x-cache: Hit from cloudfront.
- Cache policy changes: wait for Deployed status, test with
curl -I twice.
- Invalidation: wait for Completed status, request path — first Miss,
second Hit.
- WAF changes: verify blocked requests now succeed.
- Lambda@Edge changes: deploy new version, wait for propagation (minutes).
Step 9: Decide — ROOT_CAUSE_FOUND vs NEED_MORE_INFO vs ESCALATE
- ROOT_CAUSE_FOUND. Walk identified a specific cache issue and config
element. Output REMEDIATION with exact change.
- NEED_MORE_INFO. Operator cannot supply evidence (logs not enabled,
policy ID unknown). Output the list of missing inputs.
- ESCALATE. Cause outside operator's scope (AWS-side event, Lambda@Edge
owned by another team, WAF managed centrally). Output escalation target.
Output format
DISTRIBUTION: <distribution ID or domain>
VERDICT: ROOT_CAUSE_FOUND | NEED_MORE_INFO | ESCALATE
ROOT_CAUSE: <cache issue name> — <specific root cause>
CACHE_ISSUE: <ORIGIN_NO_CACHE | ORIGIN_NO_STORE | CACHE_POLICY_TOO_NARROW |
CACHE_KEY_BLOAT | TTL_TOO_SHORT | STALE_NO_INVALIDATION |
ORIGIN_HEADER_OVERRIDE | LAMBDA_EDGE_MUTATION | WAF_BLOCK |
COMPRESSION_CACHE_KEY | ORIGIN_ERROR | UNKNOWN>
EVIDENCE:
- <origin response header>: <value>
- <cache policy field>: <value>
- <x-edge-result-type from access logs>: <value>
ROOT_CAUSE_CATALOG: #<N>
REMEDIATION:
1. <specific config change with CLI command>
2. <verification command>
3. <post-apply monitoring>
See references/worked-examples.md for full worked examples (origin
no-store, User-Agent cache key bloat).
STRICT output contract
This section codifies the exact output shape the eval harness asserts
against. Every invocation MUST produce output that matches this contract.
Required output structure
Every response MUST be a single block with these literal labels, in this
order:
DISTRIBUTION: <distribution ID or domain>
VERDICT: ROOT_CAUSE_FOUND | NEED_MORE_INFO | ESCALATE
ROOT_CAUSE: <cache issue name> — <specific root cause>
CACHE_ISSUE: <ORIGIN_NO_CACHE | ORIGIN_NO_STORE | CACHE_POLICY_TOO_NARROW |
CACHE_KEY_BLOAT | TTL_TOO_SHORT | STALE_NO_INVALIDATION |
ORIGIN_HEADER_OVERRIDE | LAMBDA_EDGE_MUTATION | WAF_BLOCK |
COMPRESSION_CACHE_KEY | ORIGIN_ERROR | UNKNOWN>
EVIDENCE:
- <signal source>: <observed value>
- <signal source>: <observed value>
- <signal source>: <observed value>
ROOT_CAUSE_CATALOG: #<N>
REMEDIATION:
1. <specific config change with CLI command>
2. <verification command>
3. <post-apply monitoring>
FORBIDDEN output patterns
- NEVER diagnose without checking the x-cache header first. A
ROOT_CAUSE_FOUND without an EVIDENCE row citing the observed
x-cache
value is rejected.
- NEVER blame the cache policy without checking origin Cache-Control
headers — the origin header overrides the policy. A ROOT_CAUSE_FOUND
citing
CACHE_POLICY_TOO_NARROW or TTL_TOO_SHORT without EVIDENCE
showing the origin's actual Cache-Control is rejected.
- NEVER suggest
/* invalidation without confirming content is stale.
/* invalidations are expensive and spike origin load. Always prefer
path-specific invalidations; reserve /* for full-site updates only.
- NEVER confuse
no-cache with no-store. no-cache allows caching
but requires revalidation (RefreshHit/RefreshMiss); no-store prohibits
caching entirely. Mislabeling is rejected.
- NEVER substitute lowercase or markdown-styled labels for the literal
all-caps
DISTRIBUTION:, VERDICT:, ROOT_CAUSE:, CACHE_ISSUE:,
EVIDENCE:, ROOT_CAUSE_CATALOG:, REMEDIATION:. The eval harness
pattern-matches on exact labels.
Perfect example output
DISTRIBUTION: E1A2B3C4D5 (d123.cloudfront.net)
VERDICT: ROOT_CAUSE_FOUND
ROOT_CAUSE: ORIGIN_NO_STORE — the origin returns "Cache-Control: no-store"
on all responses, which instructs CloudFront never to cache.
CACHE_ISSUE: ORIGIN_NO_STORE
EVIDENCE:
- curl -I https://origin.example.com/api/data: response includes
"Cache-Control: no-store"
- curl -I https://d123.cloudfront.net/api/data: "x-cache: Miss from
cloudfront" on every request; "Age: 0"
- get-cache-policy: CachePolicyId is CachingOptimized
(658327ea-f89d-4fab-a63d-7e88639e58f6), MinTTL=1, DefaultTTL=86400
— the policy is correct; the origin header overrides it
- CloudFront access logs: x-edge-result-type "Miss" on 100% of requests
to /api/data/*
ROOT_CAUSE_CATALOG: #1 (origin sends no-store)
REMEDIATION:
1. Update the origin to send Cache-Control: public, max-age=3600 for
cacheable API responses. For an S3 origin:
aws s3api copy-object --bucket my-bucket --key api/data.json \
--copy-source my-bucket/api/data.json \
--cache-control "public, max-age=3600" \
--metadata-directive REPLACE
2. Verify the origin header:
curl -sI https://origin.example.com/api/data | grep -i cache-control
Expect: "Cache-Control: public, max-age=3600"
3. Request via CloudFront twice; the second request should show
"x-cache: Hit from cloudfront":
curl -sI https://d123.cloudfront.net/api/data | grep -i x-cache
Anti-Patterns — NEVER (top 5)
- NEVER assume the cache policy TTL controls caching when the origin sends
Cache-Control: no-store. The origin header overrides the policy unless
explicitly overridden. Always check the origin's Cache-Control first.
- NEVER include
User-Agent in the cache key — thousands of distinct
values fragment the cache. If response truly varies by client, normalize
the header before including it.
- NEVER use
CookiesConfig.CookieBehavior: all unless the response truly
varies by every cookie. Use whitelist with only cookies that affect
the response.
- NEVER invalidate
/* when path-specific invalidation suffices — /*
clears the entire cache, spiking origin load. Use specific paths.
- NEVER set
MaxTTL lower than MinTTL on a cache policy. Always ensure
MinTTL <= DefaultTTL <= MaxTTL.
See references/worked-examples.md for additional anti-patterns (no-cache
vs no-store confusion, x-cache Hit meaning, Accept-Encoding for compressed
content, static vs dynamic mixing).
Diagnostic command quick reference
Diagnostic command quick-reference listing (config, cache policy, invalidations, CacheHitRate, x-cache probes, origin bypass, Lambda@Edge) moved verbatim to references/diagnostic-commands.md.
Load on demand for live-account probing.
See references/diagnostic-commands.md for the full command script per
cache issue category.
Recent AWS features (2024-2026)
Recent AWS features (2024-2026) moved verbatim to references/advanced-patterns.md.
Load on demand when Functions vs Lambda@Edge timing, KeyValueStore, Origin Shield metrics, or Logs-to-CloudWatch are in play.
References
references/cache-key-model.md — full cache key model with worked examples
references/diagnostic-commands.md — canonical command script per cache issue
references/worked-examples.md — worked examples, managed policy reference,
cache key normalization, and Lambda@Edge edge cases
- references/advanced-patterns.md — senior-engineer heuristics and recent AWS features (2024-2026) moved from SKILL.md
Domain
AWS CloudOps / CloudFront CDN Caching, Cache Policy, and Edge Performance.
AWS documentation
1---2name: cloudfront-cache-troubleshooter3description: Diagnoses CloudFront caching issues via a symptom-to-cause decision tree covering cache misses on every request, stale content served, unexpected cache key variation, 403/404 errors from cache, and low cache hit ratio. Walks Cache-Control headers from origin, cache policy configuration (managed vs custom), TTL settings, query string/header/cookie inclusion in cache key, x-edge-result-type and x-cache headers in access logs, Lambda@Edge response modifications, and WAF blocks. Emits a deterministic verdict (ROOT_CAUSE_FOUND | NEED_MORE_INFO | ESCALATE) with the specific cache issue and evidence from CloudFront access logs, cache policy inspection, and curl response headers. Use when content is not cached, stale content is served, hit ratio is low, or CloudFront returns 403/404 unexpectedly.4license: Apache-2.05compatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). Offline diagnosis works from pasted response headers, access log excerpts, and cache policy JSON. Live-account diagnosis uses aws cloudfront get-distribution-config, get-cache-policy, aws cloudfront get-monitoring-sample, curl -I against the distribution and origin, and CloudFront access logs via aws logs get-log-events (AWS CLI v2, SSO or key-based credentials).6metadata:7 source: https://skillmd.com/skills/jhkchan/cloudfront-cache-troubleshooter8 domain: aws-cloudops9 complexity: high10 requires_llm: 'true'11 phase: '2'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: Networking15 task_type: troubleshoot16 skill_class: capability17 verdict_shape: ROOT_CAUSE_FOUND | NEED_MORE_INFO | ESCALATE18 lifecycle_status: active19 when_to_use: Diagnosing CloudFront cache misses on every request, stale content being served, unexpected cache key variation (different content per user), 403/404 errors from the cache edge, low cache hit ratio with elevated origin load, or Lambda@Edge / WAF interference with caching; validating whether the root cause is origin headers, cache policy misconfiguration, TTL settings, invalidation gaps, or cache key bloat.20 when_not_to_use: CloudFront distribution configuration posture audits (use cloudfront-distribution-auditor), origin failover / multi-origin setup (use cloudfront-distribution-deployer), TLS certificate issues on the distribution (use acm-certificate-expiry-auditor), or WAF rule authoring (use wafv2-web-acl-auditor). This skill diagnoses caching root cause; it does not audit distribution security posture.21 activation_triggers: CloudFront cache miss every request, CloudFront not caching, CloudFront stale content, CloudFront content not updating, CloudFront cache hit ratio low, CloudFront origin load high, CloudFront 403 from cache, CloudFront 404 from edge, CloudFront different content per user, CloudFront cache key variation, CloudFront cache policy misconfigured, x-cache Miss from cloudfront, x-edge-result-type Miss, troubleshoot CloudFront caching22 invocation_schema: 'Input: either (a) a symptom description (cache miss pattern, stale content report, hit-ratio drop), optionally paired with cache policy JSON and response headers, OR (b) a distribution ID plus caller context (origin URL, observed x-cache header, access log excerpt) for live-account diagnosis. Output: a deterministic DISTRIBUTION / VERDICT / ROOT_CAUSE / CACHE_ISSUE / EVIDENCE / REMEDIATION block where VERDICT ∈ {ROOT_CAUSE_FOUND, NEED_MORE_INFO, ESCALATE} and CACHE_ISSUE ∈ {ORIGIN_NO_CACHE, ORIGIN_NO_STORE, CACHE_POLICY_TOO_NARROW, CACHE_KEY_BLOAT, TTL_TOO_SHORT, STALE_NO_INVALIDATION, ORIGIN_HEADER_OVERRIDE, LAMBDA_EDGE_MUTATION, WAF_BLOCK, COMPRESSION_CACHE_KEY, ORIGIN_ERROR, UNKNOWN}.'23 version: 0.1.024 author: Jacky Chan — AWS Community Builder25 keywords: CloudFront, caching, cache miss, cache hit ratio, stale content, cache key, cache policy, Cache-Control, max-age, no-cache, no-store, TTL, x-edge-result-type, x-cache, Lambda@Edge, origin shield, managed policy, AllViewerExceptReservedHeader, invalidation, troubleshooting26 tags: cloudfront, networking, troubleshoot, caching, cdn, cache-policy, ttl, lambda-at-edge27---2829# CloudFront Cache Troubleshooter3031## Activation3233Activate this skill when the user reports a CloudFront caching issue.34Trigger phrases: "CloudFront cache miss every request", "CloudFront not35caching", "CloudFront stale content", "CloudFront content not updating",36"CloudFront cache hit ratio low", "CloudFront origin load high",37"CloudFront 403 from cache", "CloudFront 404 from edge", "CloudFront38different content per user", "CloudFront cache key variation", "CloudFront39cache policy misconfigured", "x-cache Miss from cloudfront",40"x-edge-result-type Miss", "troubleshoot CloudFront caching".4142## Mindset4344**One-line takeaway:** every CloudFront caching problem is a mismatch45between what the cache key captures, what the origin allows to be cached,46and what the cache policy TTL instructs. The diagnostic walk identifies47which of these three is broken.4849Three facts make CloudFront cache diagnosis different:5051- **CloudFront caches by cache key, not by URL alone.** The cache key =52 URL path + query strings + headers + cookies (per the cache policy).53 Including `User-Agent` fragments the cache so badly that hit ratio54 drops to near zero.55- **Origin `Cache-Control` headers dominate unless the cache policy56 overrides them.** If the origin sends `Cache-Control: no-store`,57 CloudFront will not cache regardless of the policy TTL.58- **`x-edge-result-type` in access logs is the ground truth.** Values:59 `Hit`, `Miss`, `RefreshHit`, `RefreshMiss`, `Error`, `LimitExceeded`,60 `CapacityExceeded`, `Denied`. `Miss` every time means cache key or61 origin headers prevent caching.6263## Expert heuristic6465Five senior-CDN-engineer heuristics (edge-only hit ratio, Lambda@Edge header rewrites, Origin Shield break-even, compression size limits, Functions vs Lambda@Edge cache timing) moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md).66Load on demand when the symptom contradicts the cache policy analysis.6768## Quick reference — symptom to cache issue6970| Observed signal | Cache issue | First probe |71|---|---|---|72| `x-edge-result-type: Miss` on every request | ORIGIN_NO_CACHE / ORIGIN_NO_STORE / CACHE_POLICY_TOO_NARROW | `curl -I` to origin for `Cache-Control`; cache policy TTL |73| Content hours/days old; origin updated | STALE_NO_INVALIDATION / TTL_TOO_LONG | Origin `max-age` vs behavior TTL; invalidation history |74| Same URL, different content per user | CACHE_KEY_BLOAT | Cache policy headers/cookies/query strings |75| 403 / 404 from CloudFront; origin returns 200 | WAF_BLOCK / LAMBDA_EDGE_MUTATION | WAF web ACL; Lambda@Edge logs |76| Hit ratio dropping; origin load rising | CACHE_KEY_BLOAT / TTL_TOO_SHORT | Cache policy `DefaultTTL`; cache key values |77| `RefreshHit` frequent; origin gets `If-Modified-Since` | TTL_EXPIRED / STALE-REVALIDATE | Origin `max-age` vs behavior `MinTTL` |7879## Process — Diagnostic decision tree (apply in order)8081### Step 0: Capture the cache signal8283| Signal | Source | Why required |84|---|---|---|85| **Distribution ID or domain** | User-provided or `list-distributions` | All get-distribution-config calls need this |86| **Symptom (miss vs stale vs variation)** | User report + `curl -I` | Drives the symptom category |87| **x-edge-result-type / x-cache** | Access logs (S3) or `curl -I` | Ground truth for edge behavior |8889If distribution/domain unknown:9091list-distributions / get-distribution-config discovery commands moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md).92Run them when the distribution ID or domain is unknown.9394### Step 1: Identify the symptom category9596| Category | Signature | Diagnostic step |97|---|---|---|98| **A. CACHE_MISS_ALWAYS** | `Miss` on every request; `x-cache: Miss from cloudfront` | Step 2 |99| **B. STALE_CONTENT** | Content old; origin updated; no invalidation sent | Step 3 |100| **C. CACHE_KEY_VARIATION** | Same URL, different content per user; hit ratio near zero | Step 4 |101| **D. ERROR_FROM_CACHE** | 403/404 from CloudFront; origin returns 200; `x-edge-result-type: Error` | Step 5 |102| **E. LOW_HIT_RATIO** | Hit ratio dropping; origin load rising; mix of Hit and Miss | Step 6 |103104Priority if multiple match: CACHE_MISS_ALWAYS > ERROR_FROM_CACHE >105CACHE_KEY_VARIATION > STALE_CONTENT > LOW_HIT_RATIO.106107### Step 2: CACHE_MISS_ALWAYS diagnostic108109Every request is a `Miss`. Cause: origin sends `no-cache`/`no-store`, cache110policy TTL is 0, `CachingDisabled` attached, or response not cacheable.111112**Diagnostic walk:**1131141. **Check origin `Cache-Control`** (#1 cause). `curl -I` directly to origin:115116```bash117# Direct to origin (bypass CloudFront):118curl -sI https://origin.example.com/path/to/content | grep -iE 'cache-control|expires|pragma|set-cookie'119120# Via CloudFront:121curl -sI https://d123.cloudfront.net/path/to/content | grep -iE 'x-cache|age|cache-control'122```123124| Origin header | Effect | Fix |125|---|---|---|126| `Cache-Control: no-store` | Never caches | Change to `public, max-age=3600` |127| `Cache-Control: no-cache` | Revalidates every request (RefreshMiss) | Change to `public, max-age=3600` |128| `Cache-Control: max-age=0` | Same as no-cache | Raise to desired TTL |129| `Cache-Control: private` | Not cached (browser-only) | Change to `public` |130| `Pragma: no-cache` | Legacy HTTP/1.0 no-cache | Remove |131| `Set-Cookie` in response | May skip caching if cookie not in policy | Add cookie to policy or remove Set-Cookie |1321332. **Check cache policy TTL:** `MinTTL: 0, DefaultTTL: 0, MaxTTL: 0` disables134 caching. Managed `CachingDisabled` (ID `4135ea2d-6df8-44a3-9df3-4b5a84be39ad`)135 explicitly sets all TTLs to 0.136137```bash138aws cloudfront get-cache-policy --id <cache-policy-id> \139 --query 'CachePolicy.CachePolicyConfig.{minTTL:MinTTL,defaultTTL:DefaultTTL,maxTTL:MaxTTL,headers:ParametersInCacheKeyAndForwardedToOrigin.HeadersConfig.HeaderBehavior}' \140 --output json141```1421433. **Check if origin returns cacheable status codes.** CloudFront caches144 200, 206, 301, 302, 304, 404 (optionally).145146**Common fixes:**147- Origin sends `no-store`: update origin to `Cache-Control: public, max-age=3600`.148 For S3: `aws s3api put-object` with `--cache-control`.149- Cache policy TTL is 0: set `DefaultTTL: 3600` or use managed150 `CachingOptimized` (`658327ea-f89d-4fab-a63d-7e88639e58f6`).151- `Set-Cookie` preventing caching: add cookie to policy or remove from response.152153### Step 3: STALE_CONTENT diagnostic154155Content served from cache but old — origin updated but CloudFront serves156cached version. Cause: TTL not expired (expected without invalidation), no157invalidation sent, or cache behavior overrides origin with longer TTL.158159**Diagnostic walk:**1601611. **Determine if invalidation is needed.** CloudFront serves cached content162 until TTL expires OR invalidation clears it. No invalidation after origin163 update = stale until TTL expires. This is expected, not a bug.1642. **Compare origin `max-age` vs cache behavior TTL.** If origin sends165 `max-age=86400` but operator expects minutes, TTL is too long.1663. **Check `OriginCacheControlHeaders` handling.** If set to respect,167 CloudFront uses origin's `max-age`. If override, uses policy `DefaultTTL`.1684. **Check invalidation history.** If invalidation sent but stale persists,169 it may be for wrong paths or still in progress.170171```bash172# List recent invalidations.173aws cloudfront list-invalidations --distribution-id <id> \174 --query 'InvalidationList.Items[*].{id:Id,status:Status,paths:InvalidationBatch.Paths.Items,created:CreateTime}' \175 --output json176177# Check the Age header (how long object has been cached):178curl -sI https://d123.cloudfront.net/path | grep -iE 'x-cache|age|cache-control'179```180181| Sub-symptom | Root cause | Fix |182|---|---|---|183| No invalidation sent, TTL not expired | Expected behaviour | Send invalidation OR wait for TTL |184| Invalidation sent but still stale | Wrong paths or in progress | Verify `get-invalidation` status; paths match |185| Origin `max-age=86400` but expects 5-min | TTL too long | Lower origin `max-age` or policy `MaxTTL` |186| Stale after deployment | No invalidation in CI/CD | Add invalidation step to deploy pipeline |187188**Common fixes:**189- Send invalidation: `aws cloudfront create-invalidation --distribution-id <id> --paths "/updated/*"`.190 Prefer specific paths over `/*` to avoid spiking origin load.191- Add invalidation to CI/CD pipeline.192- For frequently-updated content, set shorter TTL (`max-age=300`).193194### Step 4: CACHE_KEY_VARIATION diagnostic195196Same URL but different content per user; hit ratio near zero. Cause: cache197key bloat — too many headers, cookies, or query strings creating unique198entries.199200**Cache key formula:** `cache key = URL path + query strings (per policy) +201headers (per policy) + cookies (per policy)`. Any value included creates a202distinct entry per unique combination.203204**Diagnostic walk:**2052061. **Read cache policy `ParametersInCacheKeyAndForwardedToOrigin`:**207208```bash209aws cloudfront get-cache-policy --id <cache-policy-id> \210 --query 'CachePolicy.CachePolicyConfig.ParametersInCacheKeyAndForwardedToOrigin' \211 --output json212```213214| Cache policy setting | Effect | Recommendation |215|---|---|---|216| `HeadersConfig.HeaderBehavior: none` | No headers in key | Default; use unless response varies |217| `QueryStringsConfig.QueryStringBehavior: all` | ALL query strings in key | Only if every param affects response |218| `CookiesConfig.CookieBehavior: all` | ALL cookies in key | Almost never correct — fragments cache |219| `CookiesConfig.CookieBehavior: whitelist` + specific | Listed cookies only | Only cookies that affect response |2202212. **Check for fragmenting headers:** `User-Agent` (thousands of values),222 `Authorization` (unique per user), `X-Forwarded-For` (unique per client).223 Do NOT include these in the cache key.2243. **Check `Accept-Encoding`** — required in cache key for compressed content.225 Managed `AllViewerExceptReservedHeader` includes it by default.2264. **Check access logs:** if every request is `Miss` for same URL, cache key227 varies per request. Compare `cs-cookie` and `cs-accept-encoding` fields.228229See `references/worked-examples.md` for the managed policy reference table230and cache key normalization details.231232**Common fixes:**233- Remove `User-Agent` from headers whitelist. Use `none` or only headers234 that affect the response.235- Switch `CookiesConfig.CookieBehavior` from `all` to `whitelist` with236 only necessary cookies.237- For static assets, use managed `CachingOptimized`.238- For dynamic APIs, use `CachingDisabled`.239240### Step 5: ERROR_FROM_CACHE diagnostic241242CloudFront returns 403 or 404; origin returns 200. Cause: WAF blocking,243Lambda@Edge modifying response, cached transient error, or wrong origin.244245**Diagnostic walk:**2462471. **Check for WAF:** `aws cloudfront get-distribution-config --id <id>248 --query 'DistributionConfig.WebACLId'`. Blocked requests return 403249 with `x-amzn-waf-action: BLOCK`.2502. **Check Lambda@Edge on behavior:** a function on `viewer-response` or251 `origin-response` can modify status code/headers/body.2523. **Check origin directly:** `curl -I` bypassing CloudFront. If origin253 returns 200 but CloudFront returns 403/404, issue is in CloudFront layer.2544. **Check for cached 404:** CloudFront caches 404 if policy allows it255 (`errorResponseCachingBehavior`). A transient 404 can persist after256 origin recovers.2575. **Check cache behavior target origin:** if pointing to deleted/wrong258 origin, origin returns 404.259260```bash261# Check WAF rules if attached:262aws wafv2 get-web-acl --scope CLOUDFRONT --id <web-acl-id> \263 --query 'WebACL.Rules[*].{name:Name,action:Action,priority:Priority}' --output json264265# Check Lambda@Edge functions:266aws cloudfront get-distribution-config --id <id> \267 --query 'DistributionConfig.DefaultCacheBehavior.LambdaFunctionAssociations.Items[*].{type:EventType,arn:LambdaFunctionARN}' \268 --output json269```270271| Sub-symptom | Root cause | Fix |272|---|---|---|273| 403 with `x-amzn-waf-action: BLOCK` | WAF blocking | Adjust WAF rules; add allowlist |274| 403 without WAF header | Lambda@Edge returning 403 | Check function logs; curl origin directly |275| 404 persists after origin recovers | Cached transient 404 | Invalidate; lower 404 cache TTL |276| 404 on specific path | Wrong TargetOriginId | Update behavior's TargetOriginId |277278See `references/worked-examples.md` for Lambda@Edge response modification279edge cases.280281### Step 6: LOW_HIT_RATIO diagnostic282283Hit ratio dropping; origin load rising; mix of Hit and Miss. Cause: cache284key bloat, TTL too short, origin sending `no-cache` on some responses, or285long-tail content (more unique URLs).286287**Diagnostic walk:**2882891. **Check `CacheHitRate` metric:**290291```bash292aws cloudwatch get-metric-statistics --namespace AWS/CloudFront \293 --metric-name CacheHitRate \294 --dimensions Name=DistributionId,Value=<id> \295 --start-time $(date -u -d '24 hours ago' +%Y-%m-%dT%H:%M:%SZ) \296 --end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) \297 --period 3600 --statistics Average --output json298```2993002. **Analyze access logs** for the Miss pattern — group by path, query301 string, headers.3023. **Check long tail:** if content catalog grew, each URL is a miss on303 first request (expected). Fix: pre-warming or accept lower ratio.3044. **Check inconsistent origin headers:** some responses with `no-cache`,305 others with `max-age=3600` = inconsistent ratio.306307| Sub-symptom | Root cause | Fix |308|---|---|---|309| Drop after traffic increase | Long-tail content | Pre-warm; accept lower ratio |310| Low for specific path | Cache key bloat on that behavior | Narrow the cache policy |311| Low with frequent `RefreshHit` | TTL expired; frequent revalidation | Raise TTL |312| Low after deploy | Invalidation cleared cache | Expected; ratio recovers |313314**Common fixes:**315- Separate static and dynamic content into different cache behaviors.316- Raise TTL for content that changes infrequently. S3 immutable objects:317 `max-age=31536000` (1 year).318- Use Origin Shield as second-tier cache.319- Pre-warm cache after deploys.320321### Step 7: Map to root-cause catalog322323| # | Root cause | Category | Fix pattern |324|---|---|---|---|325| 1 | Origin sends `Cache-Control: no-store` or `no-cache` | CACHE_MISS_ALWAYS (ORIGIN_NO_CACHE) | Update origin to `public, max-age=<TTL>` |326| 2 | Cache policy TTL is 0 or `CachingDisabled` | CACHE_MISS_ALWAYS (CACHE_POLICY_TOO_NARROW) | Switch to `CachingOptimized` or set `DefaultTTL > 0` |327| 3 | No invalidation after origin update | STALE_CONTENT (STALE_NO_INVALIDATION) | Send invalidation; add to CI/CD |328| 4 | TTL too long for frequently-updated content | STALE_CONTENT (TTL_TOO_LONG) | Lower `max-age` or policy `MaxTTL` |329| 5 | `User-Agent` or `Authorization` in cache key | CACHE_KEY_VARIATION (CACHE_KEY_BLOAT) | Remove from cache policy headers |330| 6 | All cookies in cache key | CACHE_KEY_VARIATION (CACHE_KEY_BLOAT) | Switch to `whitelist` with necessary cookies |331| 7 | WAF blocking requests | ERROR_FROM_CACHE (WAF_BLOCK) | Adjust WAF rules; add allowlist |332| 8 | Lambda@Edge modifying response | ERROR_FROM_CACHE (LAMBDA_EDGE_MUTATION) | Fix function; remove from behavior |333| 9 | Cached transient 404 | ERROR_FROM_CACHE (ORIGIN_ERROR) | Invalidate; lower 404 cache TTL |334| 10 | `Accept-Encoding` not in cache key for compressed content | CACHE_KEY_VARIATION (COMPRESSION_CACHE_KEY) | Add `Accept-Encoding` to policy |335336### Step 8: Verify the fix337338- **Origin header changes:** verify with `curl -I`, request via CloudFront339 twice — second should show `x-cache: Hit from cloudfront`.340- **Cache policy changes:** wait for Deployed status, test with `curl -I` twice.341- **Invalidation:** wait for Completed status, request path — first Miss,342 second Hit.343- **WAF changes:** verify blocked requests now succeed.344- **Lambda@Edge changes:** deploy new version, wait for propagation (minutes).345346### Step 9: Decide — ROOT_CAUSE_FOUND vs NEED_MORE_INFO vs ESCALATE347348- **ROOT_CAUSE_FOUND.** Walk identified a specific cache issue and config349 element. Output REMEDIATION with exact change.350- **NEED_MORE_INFO.** Operator cannot supply evidence (logs not enabled,351 policy ID unknown). Output the list of missing inputs.352- **ESCALATE.** Cause outside operator's scope (AWS-side event, Lambda@Edge353 owned by another team, WAF managed centrally). Output escalation target.354355## Output format356357```text358DISTRIBUTION: <distribution ID or domain>359VERDICT: ROOT_CAUSE_FOUND | NEED_MORE_INFO | ESCALATE360ROOT_CAUSE: <cache issue name> — <specific root cause>361CACHE_ISSUE: <ORIGIN_NO_CACHE | ORIGIN_NO_STORE | CACHE_POLICY_TOO_NARROW |362 CACHE_KEY_BLOAT | TTL_TOO_SHORT | STALE_NO_INVALIDATION |363 ORIGIN_HEADER_OVERRIDE | LAMBDA_EDGE_MUTATION | WAF_BLOCK |364 COMPRESSION_CACHE_KEY | ORIGIN_ERROR | UNKNOWN>365EVIDENCE:366 - <origin response header>: <value>367 - <cache policy field>: <value>368 - <x-edge-result-type from access logs>: <value>369ROOT_CAUSE_CATALOG: #<N>370REMEDIATION:371 1. <specific config change with CLI command>372 2. <verification command>373 3. <post-apply monitoring>374```375376See `references/worked-examples.md` for full worked examples (origin377no-store, User-Agent cache key bloat).378379## STRICT output contract380381This section codifies the exact output shape the eval harness asserts382against. Every invocation MUST produce output that matches this contract.383384### Required output structure385386Every response MUST be a single block with these literal labels, in this387order:388389```text390DISTRIBUTION: <distribution ID or domain>391VERDICT: ROOT_CAUSE_FOUND | NEED_MORE_INFO | ESCALATE392ROOT_CAUSE: <cache issue name> — <specific root cause>393CACHE_ISSUE: <ORIGIN_NO_CACHE | ORIGIN_NO_STORE | CACHE_POLICY_TOO_NARROW |394 CACHE_KEY_BLOAT | TTL_TOO_SHORT | STALE_NO_INVALIDATION |395 ORIGIN_HEADER_OVERRIDE | LAMBDA_EDGE_MUTATION | WAF_BLOCK |396 COMPRESSION_CACHE_KEY | ORIGIN_ERROR | UNKNOWN>397EVIDENCE:398 - <signal source>: <observed value>399 - <signal source>: <observed value>400 - <signal source>: <observed value>401ROOT_CAUSE_CATALOG: #<N>402REMEDIATION:403 1. <specific config change with CLI command>404 2. <verification command>405 3. <post-apply monitoring>406```407408### FORBIDDEN output patterns4094101. **NEVER diagnose without checking the x-cache header first.** A411 ROOT_CAUSE_FOUND without an EVIDENCE row citing the observed `x-cache`412 value is rejected.4132. **NEVER blame the cache policy without checking origin Cache-Control414 headers — the origin header overrides the policy.** A ROOT_CAUSE_FOUND415 citing `CACHE_POLICY_TOO_NARROW` or `TTL_TOO_SHORT` without EVIDENCE416 showing the origin's actual `Cache-Control` is rejected.4173. **NEVER suggest `/*` invalidation without confirming content is stale.**418 `/*` invalidations are expensive and spike origin load. Always prefer419 path-specific invalidations; reserve `/*` for full-site updates only.4204. **NEVER confuse `no-cache` with `no-store`.** `no-cache` allows caching421 but requires revalidation (RefreshHit/RefreshMiss); `no-store` prohibits422 caching entirely. Mislabeling is rejected.4235. **NEVER substitute lowercase or markdown-styled labels for the literal424 all-caps `DISTRIBUTION:`, `VERDICT:`, `ROOT_CAUSE:`, `CACHE_ISSUE:`,425 `EVIDENCE:`, `ROOT_CAUSE_CATALOG:`, `REMEDIATION:`.** The eval harness426 pattern-matches on exact labels.427428### Perfect example output429430```text431DISTRIBUTION: E1A2B3C4D5 (d123.cloudfront.net)432VERDICT: ROOT_CAUSE_FOUND433ROOT_CAUSE: ORIGIN_NO_STORE — the origin returns "Cache-Control: no-store"434 on all responses, which instructs CloudFront never to cache.435CACHE_ISSUE: ORIGIN_NO_STORE436EVIDENCE:437 - curl -I https://origin.example.com/api/data: response includes438 "Cache-Control: no-store"439 - curl -I https://d123.cloudfront.net/api/data: "x-cache: Miss from440 cloudfront" on every request; "Age: 0"441 - get-cache-policy: CachePolicyId is CachingOptimized442 (658327ea-f89d-4fab-a63d-7e88639e58f6), MinTTL=1, DefaultTTL=86400443 — the policy is correct; the origin header overrides it444 - CloudFront access logs: x-edge-result-type "Miss" on 100% of requests445 to /api/data/*446ROOT_CAUSE_CATALOG: #1 (origin sends no-store)447REMEDIATION:448 1. Update the origin to send Cache-Control: public, max-age=3600 for449 cacheable API responses. For an S3 origin:450 aws s3api copy-object --bucket my-bucket --key api/data.json \451 --copy-source my-bucket/api/data.json \452 --cache-control "public, max-age=3600" \453 --metadata-directive REPLACE454 2. Verify the origin header:455 curl -sI https://origin.example.com/api/data | grep -i cache-control456 Expect: "Cache-Control: public, max-age=3600"457 3. Request via CloudFront twice; the second request should show458 "x-cache: Hit from cloudfront":459 curl -sI https://d123.cloudfront.net/api/data | grep -i x-cache460```461462## Anti-Patterns — NEVER (top 5)4634641. NEVER assume the cache policy TTL controls caching when the origin sends465 `Cache-Control: no-store`. The origin header overrides the policy unless466 explicitly overridden. Always check the origin's `Cache-Control` first.4672. NEVER include `User-Agent` in the cache key — thousands of distinct468 values fragment the cache. If response truly varies by client, normalize469 the header before including it.4703. NEVER use `CookiesConfig.CookieBehavior: all` unless the response truly471 varies by every cookie. Use `whitelist` with only cookies that affect472 the response.4734. NEVER invalidate `/*` when path-specific invalidation suffices — `/*`474 clears the entire cache, spiking origin load. Use specific paths.4755. NEVER set `MaxTTL` lower than `MinTTL` on a cache policy. Always ensure476 `MinTTL <= DefaultTTL <= MaxTTL`.477478See `references/worked-examples.md` for additional anti-patterns (no-cache479vs no-store confusion, x-cache Hit meaning, Accept-Encoding for compressed480content, static vs dynamic mixing).481482## Diagnostic command quick reference483484Diagnostic command quick-reference listing (config, cache policy, invalidations, CacheHitRate, x-cache probes, origin bypass, Lambda@Edge) moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md).485Load on demand for live-account probing.486487See `references/diagnostic-commands.md` for the full command script per488cache issue category.489490## Recent AWS features (2024-2026)491492Recent AWS features (2024-2026) moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md).493Load on demand when Functions vs Lambda@Edge timing, KeyValueStore, Origin Shield metrics, or Logs-to-CloudWatch are in play.494495## References496497- `references/cache-key-model.md` — full cache key model with worked examples498- `references/diagnostic-commands.md` — canonical command script per cache issue499- `references/worked-examples.md` — worked examples, managed policy reference,500 cache key normalization, and Lambda@Edge edge cases501- [references/advanced-patterns.md](references/advanced-patterns.md) — senior-engineer heuristics and recent AWS features (2024-2026) moved from SKILL.md502503## Domain504505AWS CloudOps / CloudFront CDN Caching, Cache Policy, and Edge Performance.506507## AWS documentation508509- **Amazon CloudFront Developer Guide** — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html510- **CloudFront caching** — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ConfiguringCaching.html511- **Cache policies** — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/controlling-the-cache-key.html512- **CloudFront access logs** — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html513- **Lambda@Edge** — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-at-the-edge.html514- **CloudFront metrics** — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudwatch-monitoring.html515- **CloudFront CLI Reference** — https://docs.aws.amazon.com/cli/latest/reference/cloudfront/