Use Lambda @ Edge custom at the edge of the site content

Lambda @ Edge AWS Lambda an extension, which is a computing service may be used to execute a function to provide custom content CloudFront. You can write in one area (US-East-1 (northern Virginia)) Node.js or Python function, and then execute them in the viewer closer to the AWS global location without preset or management server. Lambda @ Edge automatically extended request from a day to several thousands of requests per second. Processing request on a viewer position closer AWS (instead of the origin server), can significantly reduce the delay and improve the user experience.

When Lambda @ Edge CloudFront distribution and associated functions, intercept request and response CloudFront CloudFront edge sites. You can perform the following CloudFront Lambda function when events occur:

  • When a request is received CloudFront viewer (Viewer requests)

  • Before forwarding the request to the source in the CloudFront (request source)

  • After CloudFront receive a response from the source (source response)

  • In the CloudFront (See response) before returning to the viewer in response to

Lambda @ Edge processing has many uses. E.g:

  • Cookie Lambda function checks and rewrites the URL, so that the user can see the different versions of the sites for A / B test.

  • CloudFront may check  User-Agent the header to the viewer apparatus used by the different objects is returned to the viewer, the header contains information about these devices. For example, CloudFront returns the size of the apparatus based on the screen image different from the image is located. Similarly, the function may consider the  Referer value of the header, and results in the image CloudFront return to the automatic program having the lowest resolution.

  • Alternatively, you can also check for other conditions in the Cookie. For example, on the sale of clothing retail site, if you use the Cookie instruct the user selects which color jacket, Lambda function may change requests to return CloudFront jacket image of the selected color.

  • When the viewer requests the source or request event occurs CloudFront, Lambda function may generate the HTTP response.

  • Function check or authorization token header, and forwards the request CloudFront inserting a header to control access to your content prior to the source.

  • Lambda function call to the network can also be sent to external resources, credential user to confirm or obtain content from more defined responses.

Guess you like

Origin www.cnblogs.com/cloudrivers/p/11617905.html