Eligible CloudFront Events
You can associate four possible CloudFront events with your Lambda@Edge functions. The following describes each event:
CloudFront Viewer Request
Triggered after the client request is received by CloudFront and before a CloudFront cache lookup is performed.
CloudFront Origin Request
Triggered before a request is forwarded from CloudFront to the origin. This event is triggered only when CloudFront forwards a request to your origin; content served from the CloudFront cache never triggers this event.
CloudFront Origin Response
Triggered after the origin response is received by CloudFront and before this response is cached by CloudFront. This event is triggered only when CloudFront forwards a request to your origin; content served from a CloudFront cache never triggers this event.
CloudFront Viewer Response
Triggered before a response is sent from CloudFront to viewers. The content can either be content that was already stored at a CloudFront cache, or content that is fetched from your origin in case CloudFront had to forward your request to the origin.
Response functions do not trigger when the origin returns an HTTP response other than 200.