Lambda@Edge Flashcards
What is Lambda@Edge?
A service that lets you run Lambda functions at AWS edge locations worldwide to customize and process content delivered by Amazon CloudFront, reducing latency.
Example: Running a Lambda@Edge function to resize images based on user device.
How is Lambda@Edge triggered?
Triggered by CloudFront events, enabling actions both when a request is received and before a response is sent to the user.
Additional Information: Lambda@Edge is triggered by events like viewer request, origin request, origin response, and viewer response.
What are typical applications for Lambda@Edge?
Personalizing Content: Adjust content based on user location or device type.
URL Rewrites: Modify URLs on the fly to streamline SEO.
Security Headers: Insert security-related HTTP headers to enhance site security.
Example: Using Lambda@Edge to dynamically change image URLs based on user location.
What advantages does Lambda@Edge offer?
Enhanced Performance: Processes requests closer to the user, speeding up content delivery.
Reduced Load: Offloads tasks from the origin server, reducing backend load.
Example: Implementing Lambda@Edge to cache frequently accessed content at edge locations.
What should developers keep in mind when using Lambda@Edge?
Statelessness: Functions must be stateless as they could run at any edge location.
Resource Limits: Functions have strict limits on runtime and memory, designed for quick execution.
Additional Information: Developers should optimize Lambda@Edge functions for quick execution to avoid timeouts.
How can Lambda@Edge customize content based on user country?
Lambda@Edge can access the CloudFront-Viewer-Country header in viewer requests to determine the user’s country. It can then dynamically modify the HTTP response to deliver localized content or redirect the user to a region-specific version of the site.