流量研究

首页>流量研究>#203

#web_cpc

1. Listen for requests to CDN, and trigger a Lambda function that hijacks any viewer request. 2. Determine if the request event is for an image and if the browser requesting the resource supports WebP based on the user-agent we receive from the request. 3. If we determine that the request is for an image and that the browser supports WebP, we replace it with therequest uri image extension with .webp and add the original extension into the request header 4. Next, we trigger a separate Lambda that hijacks any CDN origin response. 5. If the request uri on the response event has a .webp extension, and the response status is a 404, we check our S3 bucket for the same image, but with the original extension, we placed into our request header in step 3. 6. If we find an image with the original extension in S3, we run a WebP conversion using Sharp and place it in the origin response, otherwise, we leave the 404 response unaltered.

© 构建我的被动收入