Soru

Zorluk: OrtaAmazon CloudFront Caching, Origins, and Security

A SysOps administrator is troubleshooting a low cache hit ratio on an Amazon CloudFront distribution that serves content from an Application Load Balancer (ALB). The administrator observes that the distribution is forwarding all query string parameters and headers to the ALB origin, which causes identical content requests with different user-agent headers and tracking query strings to be cached as separate objects. The origin application only requires the session_id query string parameter to function correctly. Which configuration change will improve the cache hit ratio while ensuring the application still receives the required parameter?

  1. A
    Create a Canonical Name (CNAME) record in Amazon Route 53 at the zone apex that forwards the session_id query string parameter to the CloudFront distribution domain name.
  2. B
    Route all traffic from the CloudFront distribution through a NAT Gateway inside the VPC to strip out any query parameters other than the session_id parameter.
  3. Configure a custom CloudFront Cache Policy that includes only the session_id query string parameter in the cache key, and associate this policy with the distribution's cache behavior.Cevap
  4. D
    Modify the Application Load Balancer target group health check settings to listen on a port that filters query parameters before traffic reaches the origin instances.

Cevap

Configure a custom CloudFront Cache Policy that includes only the session_id query string parameter in the cache key, and associate this policy with the distribution's cache behavior.
The correct option is to configure a custom Cache Policy containing only the session_id query string parameter. Cache Policies determine the values (headers, cookies, and query strings) that make up the cache key. By limiting the cache key to only the session_id parameter, CloudFront ignores other variables like tracking parameters or User-Agent headers, thereby consolidating requests for identical objects into a single cache hit while still ensuring that session_id is forwarded to the origin.

Adım Adım Çözüm

1
Identify which parameters must be included in the cache key to maximize cache hit efficiency while meeting application requirements.
Determine that only the session_id query string parameter should be part of the cache key, and all other headers and query strings must be ignored.
Including unnecessary headers (like User-Agent) or query strings (like tracking IDs) in the cache key makes otherwise identical requests unique, degrading the cache hit ratio.
2
Determine the appropriate CloudFront policy type that controls cache key composition.
Select a Cache Policy rather than an Origin Request Policy.
Cache Policies explicitly define what request values are included in the cache key and thus determine cacheability, whereas Origin Request Policies only control forwarding parameters without affecting the cache key.
3
Create and associate a custom Cache Policy containing the session_id query string parameter.
Apply the new Cache Policy to the relevant cache behavior of the CloudFront distribution.
This updates the cache behavior settings, instructing CloudFront edge locations to apply the new cache key logic to all incoming viewer requests.

Anahtar Kavram

CloudFront Cache Policies manage cache key composition to optimize cache hit ratios by controlling which headers, cookies, and query strings are included in cache lookups.
Bu soruyu puanla