Lambda@Edge is a feature of Amazon CloudFront that lets you run code closer to users of your application, which improves performance and reduces latency.
https://aws.amazon.com/lambda/edge/
Features
- Lambda@Edge runs code across AWS locations globally without provisioning or managing servers, responding to end-users at the lowest network latency.
Triggers
There are 4 stages that you can attach Lambda functions.
- Viewer Request: When an end- user makes an HTTP(S) request to CloudFront, and the request arrives at the edge location closest to that user.
- Viewer Response: When the CloudFront server at the edge is ready to respond to the end-user
- Origin Request: When the CloudFront edge server does not already have the requested object in its cache, and the viewer request is ready to be sent to your backend origin webserver
- You can control the origin source based on the user’s location.
- Origin Response: When the CloudFront server at the edge receives a response from your backend origin server.