Does AWS Serverless image handler store the derivatives?

Viewed 520

I've deployed the AWS Cloud formation Serverless image handler to resize images in an S3 bucket which is working well. It is using Cloudfront, API Gateway, Lamdba, and a custom domain.

I'm looking at the requests coming out of the Lambda function and it looks to me like every resized image is regenerated nearly every time. I'm guessing they're cached by the Cloudfront distribution for a short period of time. I presume this is how the Cloudformation was designed.

This means that I'm generating more calls to the Lambda function than is strictly necessary. When I've done this myself in the past I've saved the derivatives back to S3 so that Lambda is never called for that size again. This caused it's own problems when an original image was updated at S3 as the derivatives weren't regenerated.

Ideally what I'd like to do is either; have derivatives returned to S3; or have the cache expiry at CF to never expire and then manually call flush on updated paths. Are either of these possible with the current design? Which would be more appropriate for serving images to a media heavy website?

0 Answers
Related