0Pricing
AWS Solutions Architect · Lesson

Cache Behaviors and TTL Settings

Define path-based cache behaviors, set minimum, default, and maximum TTLs, and use cache-control headers to fine-tune caching.

Cache Behaviors: What Are They?

Cache behaviors are the rules that tell CloudFront how to handle requests for different URL path patterns. Each cache behavior maps a path pattern (e.g., /images/*, /api/*, *.css) to a specific origin and caching configuration.

A distribution has one Default Cache Behavior (matching all paths not caught by more specific behaviors) and up to 25 additional path-based behaviors. CloudFront evaluates behaviors in order from most specific to least specific, then falls through to the default.

Path Pattern Matching

Path patterns support wildcards: * matches any combination of characters including slashes, and ? matches any single character. Examples:

  • /images/* — all URLs starting with /images/
  • *.jpg — all requests ending in .jpg anywhere in the path
  • /api/v2/* — all API v2 routes
  • /static/??.css — static CSS files with exactly two characters before .css

Behaviors are evaluated in the order listed in the distribution configuration. Put more specific patterns first. The default behavior (*) always matches last.

All lessons in this course

  1. CloudFront Distributions and Origins
  2. Cache Behaviors and TTL Settings
  3. Signed URLs, Signed Cookies, and Geo-Restriction
  4. CloudFront with WAF and Lambda@Edge
← Back to AWS Solutions Architect