Feature | CloudFront Functions | Lambda@Edge |
Runtime Support | JavaScript | Node.js, Python |
Request Volume | Millions of requests per second | Thousands of requests per second |
CloudFront Triggers | Viewer Request / Viewer Response | Viewer Request / Viewer Response / Origin Request / Origin Response |
Max Execution Time | < 1 ms | 5–10 seconds |
Max Memory | 2 MB | 128 MB – 10 GB |
Total Package Size | 10 KB | 1 MB – 50 MB |
Network & File System Access | No | Yes |
Access to Request Body | No | Yes |
Pricing | Free tier, ~1/6th cost of Lambda@Edge | Charged per request & duration (no free tier) |
CloudFront Functions → ultra-fast, lightweight customizations at the edge.Lambda@Edge → advanced logic with network, file system, or request body access.
CloudFront Functions – Typical Use Cases
- Cache key normalization – adjust request attributes (headers, cookies, query strings, URL) to optimize caching.
- Header manipulation – insert, modify, or remove HTTP headers.
- URL rewrites and redirects.
- Lightweight authentication/authorization – validate simple user-generated tokens (e.g., JWT) to allow or deny requests.
Lambda@Edge – Typical Use Cases
- When you need:
- Longer execution time and higher memory allocation.
- Third-party libraries (e.g., AWS SDK to call other AWS services).
- Network access to external APIs.
- File system access or request body inspection.
- Complex processing beyond simple header or URL changes.