โšก ๐‹๐ž๐ญ'๐ฌ ๐ƒ๐ž๐ฌ๐ข๐ ๐ง ๐˜๐จ๐ฎ๐ซ ๐Ž๐ฐ๐ง ๐‚๐ฅ๐จ๐ฎ๐๐ข๐ง๐š๐ซ๐ฒ (๐ˆ๐ฆ๐š๐ ๐ž ๐Ž๐ฉ๐ญ๐ข๐ฆ๐ข๐ณ๐š๐ญ๐ข๐จ๐ง ๐Ž๐ง ๐ญ๐ก๐ž ๐†๐Ž): ๐€ ๐•๐ž๐ซ๐ฒ ๐’๐ข๐ฆ๐ฉ๐ฅ๐ž ๐„๐ฑ๐ฉ๐ฅ๐š๐ง๐š๐ญ๐ข๐จ๐ง โšก

Designing your own Cloudinary - Let's Go

Mentor

Blog

Image Optimization using Amazon CloudFront and AWS Lambda.

๐“๐ž๐œ๐ก ๐’๐ญ๐š๐œ๐ค๐ฌ ๐Ÿ”ฅ :

1. AWS CloudFront

2. AWS S3

3. AWS Lambda

4. CloudFront Functions

๐„๐ฑ๐ฉ๐ฅ๐š๐ข๐ง๐ข๐ง๐  ๐€๐ซ๐œ๐ก๐ข๐ญ๐ž๐œ๐ญ๐ฎ๐ซ๐ž:

1. The user sends a HTTP request for an image with specific transformations, such as encoding and size. For ex: https://lnkd.in/gbsRSvwv

2. The request is processed by a nearby CloudFront edge location providing the best performance. Before passing the request upstream, a CloudFront Function is executed on viewer request event to rewrite the request URL.

3. If the requested image is already cached in CloudFront then there will be a cache hit and the image is returned from CloudFront cache.

4. If the Image is not in CloudFront cache, then the request will be forwarded to an S3 bucket, which is created to store the transformed images. If the requested image is already transformed and stored in S3, then it is simply served and cached in CloudFront.

5. Otherwise, S3 will respond with a 403 error code, which is detected by CloudFrontโ€™s Origin Failover. CloudFront retries the same URL but this time using the secondary origin based on Lambda function URL. When invoked, the Lambda function downloads the original image from another S3 bucket, where original images are stored, transforms it using Sharp library, stores the transformed image in S3, then serve it through CloudFront where it will be cached for future requests.

๐–๐จ๐š๐ก, ๐–๐ž ๐ฃ๐ฎ๐ฌ๐ญ ๐Ÿ๐ข๐ง๐ข๐ฌ๐ก๐ž๐ ๐ญ๐ก๐ž ๐๐ž๐ฌ๐ข๐ ๐ง๐ข๐ง๐  ๐ญ๐ก๐ž ๐‚๐ฅ๐จ๐ฎ๐๐ข๐ง๐š๐ซ๐ฒ! ๐˜๐ž๐š๐ก, ๐ข๐ญ ๐ฐ๐š๐ฌ ๐ž๐š๐ฌ๐ฒ ๐๐จ๐ž๐ฌ๐ง'๐ญ ๐ข๐ญ ๐Ÿ˜‡.

๐‡๐ž๐ซ๐ž'๐ฌ ๐š ๐Ÿ๐ฎ๐ฅ๐ฅ ๐›๐ฅ๐จ๐  ๐ข๐ง ๐๐ž๐ญ๐š๐ข๐ฅ: https://aws.amazon.com/blogs/networking-and-content-delivery/image-optimization-using-amazon-cloudfront-and-aws-lambda/