Moving Static Assets Out of Lambda Functions
Explore how to optimize serverless applications by serving static assets directly from S3 instead of Lambda functions. Understand the cost and performance benefits, and learn techniques for managing client-side file uploads and downloads efficiently in your AWS environment.
We'll cover the following...
Fetching static assets
Traditional web applications bundle code and assets, and web servers are responsible for sending both to client devices. Translated to the Lambda world, that would mean including client-side JavaScript and web assets in a Lambda function, and creating at least another API endpoint and a new function to send those files to clients on demand.
Serving application contents such as images, style sheets, client-side JavaScript and HTML files through a Lambda function is a bad idea. Those files are typically public and require no authorisation. They do not change depending on individual users or requests. Paying for a Lambda function and an API call for every file request would increase operational costs significantly and introduce two unnecessary intermediaries between the user and file ...